Check if a string is camelCase
A tiny, zero-dependency utility that returns true if a string is valid camelCase (starts lowercase, with uppercase letters separating words). Built with TypeScript — types included out of the box.
camelCase is a naming convention where the first word is lowercase and subsequent words are capitalized with no separators:
helloWorld— camelCasegetElementById— camelCaseHelloWorld— not camelCase (PascalCase)hello-world— not camelCase (kebab-case)hello_world— not camelCase (snake_case)
npm install is-camel-caseimport { isCamelCase } from "is-camel-case";
isCamelCase("fooBar"); // true
isCamelCase("helloWorld"); // true
isCamelCase("getElementById"); // true
isCamelCase("parseJSON"); // true
isCamelCase("getV2Api"); // true
isCamelCase("foo"); // false (no uppercase letter)
isCamelCase("FooBar"); // false (PascalCase)
isCamelCase("foo-bar"); // false (kebab-case)
isCamelCase("foo_bar"); // false (snake_case)
isCamelCase("FOO_BAR"); // false (SCREAMING_CASE)
isCamelCase(""); // false (empty string)
isCamelCase("1fooBar"); // false (starts with number)const { isCamelCase } = require("is-camel-case");Types are included — no need to install @types/is-camel-case.
import { isCamelCase } from "is-camel-case";
// isCamelCase(str: string) => boolean- is-kebab-case — Check if a string is kebab-case
MIT - Piyush Jha