camelcase

Convert dash, dot, underscore, or space separated strings to camelCase or PascalCase, with full Unicode support.

Library
npm
v9.0.0
698stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
51/100Fair
Development Activity32
Maintenance24
Community68
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture72
Code Quality88
Innovation68
Learning Curve90

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, and foo bar all into fooBar.
  • PascalCase mode - the pascalCase option uppercases the first character for FooBar-style output.
  • Unicode-correct casing - uses Unicode-aware regexes and toLocaleLowerCase/toLocaleUpperCase so 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 preserveConsecutiveUppercase option keeps acronyms like BAR intact instead of collapsing them to Bar.
  • Configurable number-boundary handling - capitalizeAfterNumber decides whether a letter following a digit starts a new capitalized word.
  • Locale-aware conversion - the locale option (or locale: false for the Unicode default algorithm) avoids surprises like Turkish i/İ case mapping.

Common Use Cases

  • Normalizing CLI arguments - converting --foo-bar style flags parsed from process.argv into camelCase object keys for an options object.
  • Mapping database/API field names - converting snake_case columns 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

TypeScript
68%
Apache 2.0

Appsmith

Developer Tools · Automation · No Code Platforms

40,825

Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.

View details
93
Repo Health
79
Technical
66
Dependency
Built with
TypeScript68%
Java21%
Updated 3 days ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,884

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
61
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
81%
Other

Directus

CMS · Low Code Platforms

37,783

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.

View details
92
Repo Health
82
Technical
76
Dependency
Built with
TypeScript81%
Vue18%
Updated 3 days ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Marketing · Automation

2,620

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
51
Repo Health
66
Technical
62
Dependency
Built with
TypeScript94%
Updated 1 months ago
TypeScript
97%
MPL 2.0

Logto

Authentication

14,510

Open-source auth infrastructure for SaaS and AI apps with OIDC, SAML, and RBAC

View details
91
Repo Health
83
Technical
63
Dependency
Built with
TypeScript97%
Updated yesterday
HTML
36%

OpenPanel

Hosting Control Panel · Devops

743

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.

View details
81
Repo Health
75
Technical
63
Dependency
Built with
HTML36%
Go32%
TypeScript25%
Updated yesterday
TypeScript
99%
Other

Teable

Databases · No Code Platforms

21,759

A no-code PostgreSQL database with spreadsheet UX, real-time collaboration, and native AI agents — built for teams that outgrow Airtable.

View details
79
Repo Health
76
Technical
63
Dependency
Built with
TypeScript99%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search