camelcase
Convert dash, dot, underscore, or space separated strings to camelCase or PascalCase, with full Unicode support.
Repository Health
Technical Analysis
camelcase is a zero-dependency string-casing utility for Node.js that converts dash-, dot-, underscore-, or space-separated input into camelCase or PascalCase. It correctly handles Unicode strings — including non-Latin scripts like Cyrillic — so it works beyond simple ASCII identifiers, and it accepts either a single string or an array of string fragments to join and case-convert in one call.
Beyond the basic conversion, it exposes options for the edge cases that trip up naive regex-based implementations: preserving consecutive uppercase acronyms (fooBAR vs fooBar), controlling whether digits create a word boundary (foo2bar vs foo2Bar), and locale-aware case mapping for languages like Turkish where default JavaScript case conversion produces incorrect results. As one of Sindre Sorhus’s long-running micro-utility packages, it’s a common transitive dependency across the npm ecosystem — used wherever CLI flags, config keys, or database columns need to be normalized into JavaScript-friendly identifier names.
What You Get
- camelCase conversion - turns
foo-bar,foo_bar,foo.bar, andfoo barall intofooBar. - PascalCase mode - the
pascalCaseoption uppercases the first character forFooBar-style output. - Unicode-correct casing - uses Unicode-aware regexes and
toLocaleLowerCase/toLocaleUpperCaseso non-Latin scripts convert correctly. - Array input support - pass an array of string fragments (e.g.
['foo', 'bar']) to join and case-convert in a single call. - Consecutive-uppercase preservation - the
preserveConsecutiveUppercaseoption keeps acronyms likeBARintact instead of collapsing them toBar. - Configurable number-boundary handling -
capitalizeAfterNumberdecides whether a letter following a digit starts a new capitalized word. - Locale-aware conversion - the
localeoption (orlocale: falsefor the Unicode default algorithm) avoids surprises like Turkishi/İcase mapping.
Common Use Cases
- Normalizing CLI arguments - converting
--foo-barstyle flags parsed fromprocess.argvinto camelCase object keys for an options object. - Mapping database/API field names - converting
snake_casecolumns or JSON keys from an external API into idiomatic JavaScript property names. - Config key normalization - turning dot- or dash-separated config keys into camelCase before merging into a settings object.
- Building code generators or scaffolding tools - producing valid camelCase or PascalCase identifiers for generated variable, class, or component names.
Under The Hood
Architecture
The package is a single-file ES module (index.js) with no internal layering — a camelCase() entry point delegates to a small set of private helpers (preserveCamelCase, processWithCasePreservation, postProcess) that each handle one phase of the transformation: normalizing existing camelCase boundaries, applying case rules per-character while tracking uppercase/number-adjacency state, and a final regex-based pass that collapses separators and capitalizes the following identifier character. The design trades a monolithic single function for a short internal pipeline, which keeps the file self-contained and dependency-free while still cleanly separating each transformation concern.
Tech Stack
Plain modern JavaScript (ESM, type: module) with a companion index.d.ts for full TypeScript types — there are no runtime dependencies at all. Tooling is limited to devDependencies: xo for linting, ava for the test suite, and tsd for type-definition testing, wired together through a single npm test script that runs all three. The package targets Node.js 20+ and ships only index.js and index.d.ts per its files field, keeping the published artifact minimal.
Code Quality
The test suite (test.js) is extensive, covering dozens of input/option combinations including Unicode edge cases, locale-specific casing (Turkish İ), array inputs, and each boolean option in combination with the others. Combined with xo (a strict ESLint preset) and tsd type-assertion tests, the project has strong quality gates for its size, and GitHub Actions CI runs the full suite across multiple Node.js versions on every push and pull request.
What Makes It Unique What distinguishes this implementation from a naive regex-replace is its attention to genuinely hard casing edge cases: Unicode-correct upper/lowercasing (rather than assuming ASCII), locale-sensitive conversion to avoid known JavaScript locale bugs, and configurable, independently toggleable rules for consecutive uppercase and digit-adjacent capitalization — behavior that most hand-rolled camelCase helpers don’t attempt to get right.
Used by 7 apps in this directory
Appsmith
Developer Tools · Automation · No Code Platforms
Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.
Bigcapital
Invoicing Finance
Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.
Directus
CMS · Low Code Platforms
Connect any SQL database and get instant REST and GraphQL APIs, a visual management Studio, and a native MCP server for AI agents — free for most organizations.
Laudspeaker
Marketing · Automation
Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.
Logto
Authentication
Open-source auth infrastructure for SaaS and AI apps with OIDC, SAML, and RBAC
OpenPanel
Hosting Control Panel · Devops
Docker-powered web hosting control panel that gives every user a fully isolated environment with dedicated web server, database, and networking — VPS-grade security on shared hardware.
Teable
Databases · No Code Platforms
A no-code PostgreSQL database with spreadsheet UX, real-time collaboration, and native AI agents — built for teams that outgrow Airtable.