# Convert to camelCase

> Converts each line to camelCase, splitting words at spaces, hyphens, underscores and case changes

Version: 1.0.0 · By Deck

- Install in Deck: deck://install-plugin?id=to-camel-case&url=https%3A%2F%2Fgithub.com%2Fyuzeguitarist%2Fdeck-plugins%2Freleases%2Fdownload%2Fplugins%2Fto-camel-case-1.0.0.zip
- Download .zip: https://github.com/yuzeguitarist/deck-plugins/releases/download/plugins/to-camel-case-1.0.0.zip
- View on GitHub: https://github.com/yuzeguitarist/deck-plugins/tree/main/plugins/to-camel-case

Or install with Terminal: 

```sh
mkdir -p ~/.deck/scripts/to-camel-case && curl -fsSL https://github.com/yuzeguitarist/deck-plugins/releases/download/plugins/to-camel-case-1.0.0.zip | tar -xf - -C ~/.deck/scripts/to-camel-case
```

## Script

```js
// Converts each line to camelCase, splitting words at spaces, hyphens, underscores, other punctuation and case changes.
function words(line) {
  const result = [];
  const runs = line.replace(/['\u2019]/g, "").match(/[\p{L}\p{M}\p{N}]+/gu) ?? [];
  for (const run of runs) {
    const spaced = run.replace(/([\p{Ll}\p{N}])(\p{Lu})/gu, "$1 $2").replace(/(\p{Lu})(\p{Lu}\p{Ll})/gu, "$1 $2");
    for (const word of spaced.split(" ")) result.push(word.toLowerCase());
  }
  return result;
}

function capitalize(word) {
  const first = String.fromCodePoint(word.codePointAt(0));
  return first.toUpperCase() + word.slice(first.length);
}

// A line without letters or digits stays as it is.
function convert(line) {
  const list = words(line);
  return list.length === 0 ? line : list.map((word, k) => (k === 0 ? word : capitalize(word))).join("");
}

function transform(input) {
  return String(input ?? "").split(/(\r\n|\r|\n)/).map((part, k) => (k % 2 === 0 ? convert(part) : part)).join("");
}
```

---

- HTML: https://deckclip.app/plugins/to-camel-case
- 中文: https://deckclip.app/zh-cn/plugins/to-camel-case.md

© 2026 Yuze Pan
