← Back to blog

snake_case vs camelCase for API Naming

snake_case vs camelCase for API Naming

Pick consistent API field naming: snake_case, camelCase, or kebab-case. Convert identifiers and avoid mixed conventions.

Why API Naming Conventions Matter More Than Taste

Field names are contracts. When one service emits snake_case and another expects camelCase, clients sprout ad-hoc mappers that rot over time. Style debates feel subjective, yet consistency reduces cognitive load, generated client quality, and documentation drift. Public HTTP JSON APIs often prefer one convention end to end, while protobuf and some RPC ecosystems lean on different defaults. Pick deliberately, publish the rule, and enforce it in review. The Case Converter on ToolsFree.org helps convert examples while you draft OpenAPI schemas.

Naming also affects caching, logging, and analytics pipelines that key on exact strings. Renaming a field is a breaking change even if the semantics stay identical. Prefer additive evolution: introduce a new field, deprecate the old, and remove later. Case conversion at the edge can smooth migrations, but silent automatic conversion hides mistakes. Make transformations explicit in adapters rather than relying on framework magic that differs by language.

Code generators amplify conventions: an inconsistent schema produces ugly client method names that developers then wrap again, adding yet another layer of renaming debt. Spending an hour normalizing the OpenAPI document saves days of adapter code across mobile, web, and partner SDKs over a year. Include naming rules in the same linter pack that checks auth schemes and error models so style is not optional during review. Treat field names as carefully as you treat URL paths and status codes in public API design meetings.

Snake_case: Readability and Historical Web Roots

Snake_case separates words with underscores: created_at, user_id, invoice_total. It mirrors common database column naming and feels natural in Python ecosystems that dominate many backends. URLs and query parameters frequently use snake_case or kebab-case. Human readers scanning JSON logs often parse underscores quickly when field names grow long. Several style guides for JSON APIs historically endorsed snake_case for that reason.

Drawbacks appear in JavaScript-centric frontends where camelCase dominates idiomatic objects. Teams bridge with serialization layers such as renaming strategies in Jackson or serde. Those layers must be tested—especially around acronyms like HTTPStatus versus http_status. Establish an acronyms policy in your style guide so converters behave predictably. Use the Case Converter to prototype conversions before locking the schema.

When absorbing a third-party webhook, write an anti-corruption layer that maps their convention into yours at the boundary and nowhere else in the core. Do not let foreign case styles bleed into your domain models and database columns casually. The Case Converter helps sketch the mapping table quickly while you draft the adapter and its tests. Keep the mapping tested in CI. Boundary discipline is how large systems stay coherent despite integrating dozens of external JSON dialects over years of product growth.

  • snake_case: created_at, device_id, error_code
  • camelCase: createdAt, deviceId, errorCode
  • PascalCase: CreatedAt (types/classes, rarely JSON fields)
  • kebab-case: created-at (headers/paths more than JSON bodies)

camelCase: JavaScript Ergonomics and Client SDKs

camelCase starts subsequent words with capitals: createdAt, deviceId. It matches JavaScript and TypeScript object property conventions, reducing friction for browser apps and Node services. Generated TypeScript clients feel native when the wire format already matches. Many commercial SaaS APIs standardized on camelCase for JSON bodies for that ecosystem fit.

Problems arise when server logs and SQL remain snake_case while API responses flip case, forcing dual mental models. Document the boundary clearly: database snake_case, HTTP camelCase, or vice versa. Avoid mixing conventions inside a single JSON object, which is a common symptom of rushed merges. Lint examples in your OpenAPI file so published docs match runtime behavior.

Publish a one-page naming cheat sheet with five good examples and five rejected ones so reviewers share a concrete reference during pull requests. Link it from the repository README and from All Tools related posts when relevant. Ambiguity shrinks when people can point to a written example instead of arguing from memory about how yesterday’s API spelled user ID fields across mobile and backend pull requests in the same sprint.

Acronyms, Numbers, and Edge Cases

Acronyms create ugly edge cases: is it userId or userID? JsonURL or JsonUrl? Pick a rule—often “capitalize only the first letter of acronyms in camelCase”—and apply it everywhere. Numbers in names (h265Profile) need similar consistency. Validators should reject spaces and punctuation other than underscores when snake_case is required.

Unicode identifiers are technically possible in JSON but a poor idea for interoperable APIs. Stick to ASCII field names. Translate human labels separately in UI copy. When importing CSV headers into JSON, run them through the Case Converter and a slug cleanup pass before accepting them as schema. Garbage in headers becomes long-lived API debt if you promote them unchanged.

{
  "user_id": 42,
  "created_at": "2026-07-18T12:00:00Z",
  "is_active": true
}

{
  "userId": 42,
  "createdAt": "2026-07-18T12:00:00Z",
  "isActive": true
}

Tooling: Linters, Serializers, and Contract Tests

Enforce naming with schema linters and CI checks that walk OpenAPI components. Contract tests should fail when a new field violates the convention. Code generators then emit idiomatic clients without surprise renames. If you must support dual conventions temporarily, version the API rather than switching based on User-Agent heuristics that age badly.

Pretty-print sample payloads in the JSON Formatter during reviews to spot inconsistent keys quickly. Hash canonical example payloads with the Hash Generator in CI to detect accidental renames. Browse All Tools for complementary helpers when preparing fixtures. Small mechanical checks prevent heated debates in pull requests by moving the rule into automation.

Public APIs vs Internal Events

Public HTTP APIs benefit from one frozen convention with a long deprecation policy. Internal event buses might follow the producer language’s norms, but organization-wide standards still pay off when many consumers exist. GraphQL often uses camelCase field names by community convention. gRPC/protobuf uses field names that generators map into language idioms—do not confuse protobuf field names with JSON transcoding settings.

When JSON transcoding is enabled for protobuf services, review the emitted JSON names explicitly. Defaults may not match your public style guide. Add golden files for transcoded responses. Never assume engineers remember the mapping under deadline pressure. Written examples beat lore.

Migrating Between Conventions Without Breaking Clients

If you must migrate, emit both fields for a season, mark one deprecated, and provide SDK releases that read the new name preferentially. Communicate timelines in changelogs and developer emails. Monitor usage of deprecated fields via analytics when possible. Remove only after usage collapses or after a hard cut negotiated with major partners.

Do not change case as a silent “cleanup” in a minor version. Semver for APIs is social as much as technical; partners pin integrations tightly. Provide a conversion script or mapping table. The Case Converter can help partners transform sample fixtures during their migration sprints. Offer a staging environment where only the new convention appears so clients can test early.

A Pragmatic Recommendation

For new JSON HTTP APIs in a JavaScript-heavy org, camelCase is a coherent default. For Python-heavy data platforms exposing JSON, snake_case may reduce end-to-end friction. Either choice beats a mix. Record the decision, lint it, and teach it during onboarding. Use ToolsFree.org tools to prepare examples quickly without bikeshedding on conversion mechanics.

Remember that naming is only one slice of API quality beside versioning, error shapes, and authentication. Still, inconsistent case is an avoidable tax. Invest once in convention tooling and reclaim hours of review nitpicks. Your future SDKs and docs site will look intentionally designed rather than accidentally assembled.

  • Pick one JSON naming convention per API surface
  • Document acronym rules explicitly
  • Enforce with OpenAPI linting in CI
  • Migrate additively with deprecation windows
JSON examples comparing snake_case and camelCase API field naming conventions

Convert identifiers between snake_case, camelCase, and more. Case Converter →

Try our free tools

Apply what you learned — instant, browser-based.