camelCase vs. snake_case: Which Should JSON Field Names Use

Should your API use camelCase or snake_case for JSON fields? This expert guide breaks down the debate from history, backend–frontend mismatch, performance myths, developer experience, and real-world practices from companies like Google and Stripe—so you can make a confident, future-proof decision.

Oliver Kingsley

Oliver Kingsley

17 December 2025

camelCase vs. snake_case: Which Should JSON Field Names Use

In the architectural design of distributed systems, APIs are not just conduits for system interaction; they are contracts connecting different tech stacks, organizational cultures, and even development eras. Within the design details of RESTful APIs, one seemingly minor topic sparks endless debate: Should JSON field names use camelCase or snake_case?

This is not merely an aesthetic choice. It touches upon the "impedance mismatch" between backend persistence layers and frontend presentation layers, involving serialization performance, network transmission efficiency, Developer Experience (DX), and cognitive psychology.

Based on the history of programming languages, underlying technical implementation mechanisms, and the architectural decisions of industry giants like Google and Stripe, this article provides an expert-level decision guide.

button

1. Historical Origins: A Semiotic Choice

To understand this debate, we must trace the evolution of computer languages. Naming conventions did not appear out of thin air; they are products of hardware limitations and community cultures of specific eras.

The Origin of snake_case: C and the Unix Philosophy

The popularity of snake_case (e.g., user_id) dates back to C and Unix in the 1970s. Although early keyboards (like the Teletype Model 33) had shift keys, many early compilers were case-insensitive. To distinguish words clearly on low-resolution displays, programmers introduced the underscore to simulate spaces in natural language. This habit became deeply rooted in SQL database standards. To this day, the default column naming style for PostgreSQL and MySQL remains snake_case, laying the groundwork for the future mapping friction between APIs and databases.

The Rise of camelCase: The Hegemony of Java and JavaScript

camelCase (e.g., userId) rose with Object-Oriented Programming (Smalltalk, C++, Java). Java established the industrial standard of "PascalCase for classes, camelCase for methods/variables." The decisive turning point was the birth of JavaScript. Although JSON originated from JS object literals, the JS standard library (e.g., getElementById) adopted camelCase across the board. As AJAX and JSON replaced XML as the dominant data exchange formats, camelCase gained "native" status in the Web domain.


2. Core Conflict: Impedance Mismatch of Tech Stacks

When data flows between different languages, it inevitably encounters "impedance mismatch."

The Backend Perspective (Python/Ruby/SQL)

In the backend, Python (PEP 8) and Ruby communities strongly recommend snake_case.

class UserProfile(BaseModel):
    first_name: str  # Python convention
    last_name: str

If the API mandates camelCase, you must configure aliases or converters in the serialization layer. While feasible, this adds a layer of mapping logic.

The Frontend Perspective (JavaScript/TypeScript)

In the browser, camelCase is the absolute ruler.

const user = await fetchUser();
console.log(user.first_name); // Violates ESLint camelcase rule
render(user.email_address);

ESLint will flag this as a warning, forcing developers to disable the rule or convert data immediately upon receipt.

// Verbose renaming
const { first_name: firstName, last_name: lastName } = response.data;

This increases boilerplate code and the likelihood of errors.


3. Performance Myths: Serialization and Network Transmission

Regarding performance, two common myths exist: "Field name conversion is too slow" and "Underscores increase payload size." Let's clarify with data.

Myth 1: Runtime Conversion Overhead

Note: Never perform global recursive conversion in the frontend (browser main thread) using interceptors (e.g., Axios). For large responses, this causes page jank and memory churn. Conclusion: The backend should handle the conversion.

Myth 2: Transmission Size and Compression

Theoretically, first_name is one byte longer than firstName. However, with Gzip or Brotli compression enabled (standard HTTP config), this difference virtually disappears.


4. Developer Experience (DX) and Cognitive Psychology

Architecture is not just about machines; it's about people.


5. Industry Standards and Rationale

Organization Choice Core Logic & Background
Google camelCase Google API Guide (AIP-140) mandates lowerCamelCase for JSON. Even if internal Protobuf definitions use snake_case, the external conversion layer automatically switches to camelCase to align with the Web ecosystem.
Microsoft camelCase With.NET Core embracing open source and the invention of TypeScript, Microsoft fully pivoted to Web standards, abandoning the early PascalCase.
Stripe snake_case A typical Ruby-stack company. They mask the difference by providing extremely robust Client SDKs. When you use the Node SDK, although snake_case is transmitted, the SDK method signatures usually follow JS conventions.
JSON:API camelCase The community-driven specification explicitly recommends camelCase, reflecting the consensus of the Web community.

6. Deep Architectural Advice: Decoupling and DTOs

A common anti-pattern is "Pass-through": directly serializing database entities to return them.

Best Practice: Introduce a DTO (Data Transfer Object) layer. Regardless of how the underlying database is named, you should define an independent API contract (DTO). Since you are defining a DTO, why not define it as camelCase to adhere to Web standards? Modern mapping tools (MapStruct, AutoMapper, Pydantic) handle this conversion effortlessly.


7. Looking Forward: GraphQL and gRPC

GraphQL: The community almost 100% embraces camelCase. If your team plans to introduce GraphQL in the future, designing REST APIs with camelCase now is a wise "forward compatibility" strategy.

gRPC: The Protobuf standard dictates: .proto files use snake_case for field definitions, but they must be converted to camelCase when mapped to JSON. This is Google's standard solution for multi-language environments.


8. Summary and Decision Matrix

There is no absolute right or wrong, only trade-offs. Here is the final decision framework:

For the vast majority of new, general-purpose RESTful APIs facing Web/App clients, camelCase is strongly recommended.

Reason: Align with the dominance of JSON/JavaScript/TypeScript, embracing the habits of 90% of consumers.

Tooling: Get the best support from OpenAPI code generators, Swagger UI, and modern IDEs.

When to use snake_case?

1. Specific Consumers: The primary users of the API are Python data scientists or system ops (Curl/Bash).

2. Legacy Systems: Existing APIs are already snake_case. Consistency > Best Practice. Do not mix styles within the same system.

3. Backend Velocity Extremism: Using Python/Ruby without the resources to maintain a DTO layer, directly passing through database models.

Decision Table

Dimension Recommended Style
Web Frontend / Mobile App camelCase (Zero impedance, type safety)
Data Analysis / Scientific Computing snake_case (Fits Python/R habits)
Node.js / Go / Java Backend camelCase (Native or perfect library support)
Python / Ruby Backend camelCase (Converter recommended) or snake_case (Internal tools only)
Full-Stack Team The higher the full-stack degree, the more camelCase is recommended

The essence of API design is empathy. In the context of Web APIs, encapsulating complexity in the backend (handling mapping) and leaving convenience to the user (adhering to JS habits) is the choice that reflects greater professionalism.

Explore more

What to Use for Shared API Collections and Versioning

What to Use for Shared API Collections and Versioning

Learn what to use for shared API collections and versioning. Discover how Apidog enables seamless API sharing, version control, and publishing to keep teams aligned and APIs consistent all from one powerful, free platform.

16 December 2025

A Practical Guide on What to Use to Design REST APIs

A Practical Guide on What to Use to Design REST APIs

What's the best tool to design REST APIs? Learn why Apidog is the top choice with its visual design-first approach, collaborative features, and integrated workflow for creating perfect APIs.

16 December 2025

What is the Software Testing Life Cycle (STLC)?

What is the Software Testing Life Cycle (STLC)?

Learn the six phases of the Software Testing Life Cycle, entry/exit criteria, and how Apidog automates API test case development and execution for faster, more reliable releases.

16 December 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs