camelCase, snake_case, kebab-case & PascalCase: Cross-Language Naming
Developers search camelCase vs snake_case, convert case online, and JSON naming convention when TypeScript front-ends meet PostgreSQL columns. Inconsistent casing breaks ORM mappings, OpenAPI clients, and GraphQL field resolvers. This guide defines each style, when REST payloads use snake_case, and how to run automated case transforms without mangling acronyms like HTTP or userID.
Layered conventions: DB, API, client
It is common for databases to store user_id while JavaScript consumes userId. Let serializers translate at the boundary. Document the mapping in OpenAPI / AsyncAPI so client codegen stays aligned.
Regex-only case flips are dangerous
Linting and CI enforcement
ESLint naming rules, SQLFluff for databases, and JSON Schema propertyNames checks catch drift early.
GraphQL, protobuf, and cross-language buffers
GraphQL field names are conventionally camelCase even when backends are snake_case—use automatic serializers so resolvers stay thin. Protocol Buffers generate idiomatic accessors per language; do not fight the compiler with manual case maps in every service. For event schemas (Avro, JSON Schema), document canonical casing in the registry and reject producer drift in CI.
URLs, file paths, and SEO alignment
kebab-case dominates public routes because it reads well in address bars and matches how people type search queries. Align slugs between marketing and API docs to reduce duplicate content—see URL slugs for SEO. Windows vs Linux path casing still trips CI: normalize early in Docker builds.
Internationalization and Unicode edge cases
Turkish dotted/dotless I breaks naive .toLowerCase() transforms. NFC vs NFD normalization changes byte sequences—store canonical forms for keys. If you expose user-generated identifiers, avoid automatic case folding that could merge distinct user intents.
Recommended tools on Universal Dev Tools
Flip between camelCase, snake_case, PascalCase, and kebab-case for quick experiments.
Normalize titles into URL-safe kebab-case strings before publishing routes.
Alphabetize identifier lists when comparing exports from different databases.
Clean lists of column or field names after case-insensitive merges.
Related guides on this blog
Frequently Asked Questions
What is camelCase vs PascalCase?
camelCase starts lowercase then capitalizes subsequent words (userId). PascalCase capitalizes every word (UserId) and is common for classes and React components in TypeScript.
When is snake_case used?
Python, Ruby, and SQL often prefer snake_case for variables and columns. APIs may expose snake_case JSON even when clients use camelCase—coordinate serialization layers.
What about kebab-case in URLs?
kebab-case (lower-with-hyphens) is typical for URLs, static files, and CSS class fragments (BEM). Avoid spaces and mixed casing to reduce cross-platform issues.
How do I rename fields across a codebase?
Use IDE refactoring, codemods, and schema migration scripts. Add temporary JSON aliases during API version transitions.
Do acronyms break case converters?
Yes—HTTP vs Http vs http requires a glossary. Automated tools need rules for consecutive capitals (XMLHttpRequest).
What does JSON API style guides recommend?
JSON:API and many REST conventions favor camelCase for attributes, but consistency beats dogma—document your choice in OpenAPI.
Wrapping up
Pick a convention per layer, automate transforms, and keep a glossary for acronyms—future you thanks past you during major refactors.
Case Converter →