Skip to content
gohacks.dev
Standard Library

JSON Key Case Converter

Rename every key in a JSON document to camelCase, snake_case, kebab-case or PascalCase, at every depth or only the top level, without touching values.

Free · No sign-up · Your inputs stay in your browser

Input

Convert JSON keys between camelCase and snake_case

Output

Converted JSON

241 characters

Only keys change; values, including strings that look like identifiers, are left alone. Two keys that collapse to the same name (user_id and userId) keep the later one, so check the key count when a payload mixes conventions.

Runs in this browser. Nothing you paste is sent to a server.

Where the conventions meet

Ruby, Python, PHP and SQL columns favour snake_case; JavaScript and most JSON APIs designed for browsers use camelCase. Converting at the boundary, once, keeps each side idiomatic. Laravel API resources usually do it with Str::camel(); in JavaScript, a small recursive function or a library such as camelcase-keys does the same thing as this tool.

Collisions

If a payload already mixes conventions, user_id and userId both become userId, and only the later value survives. Check the key count before and after on unfamiliar data.

Share

Frequently asked questions

Does converting keys change string values that look like keys?
No. Only object keys are renamed. A value such as "first_name" stays exactly as it was.
How are acronyms handled?
A run of capitals is kept together as one word, so userIDs becomes user_ids and HTTPServer becomes http_server.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools