Convert camelCase to snake_case!

String
Result

Convert camelCase to snake_case!

Is the variable naming in the code you copied from somewhere else different from your code? Don't worry! It converts variables to your desired naming convention!

This page rewrites camelCase identifiers such as userId or lastLoginAt into snake_case (user_id, last_login_at) inside whatever text you paste: a JS object, a JSON body, a TypeScript interface or a plain list of names.

The typical reason is a boundary between ecosystems. A frontend or Java service names fields in camelCase, while the Python code, the PostgreSQL/MySQL columns or the analytics schema on the other side expect snake_case. Instead of retyping each key, paste the block and copy the converted version.

How to use

  1. Leave the dropdowns on camelCase → snake_case (this page opens with that pair selected).
  2. Replace the sample in the String box with your code or field list; the Result box updates as you type and highlights every renamed identifier.
  3. Use the copy button on the Result box, or select all and copy, then paste it back into your editor.

Example

Input (camelCase)
const payload = {
  userId: 42,
  displayName: "Mina",
  isActive: true,
  lastLoginAt: "2024-05-01T09:30:00Z",
};
Output (snake_case)
const payload = {
  user_id: 42,
  display_name: "Mina",
  is_active: true,
  last_login_at: "2024-05-01T09:30:00Z",
};

Only words that contain an uppercase letter after a lowercase start are treated as camelCase, so the single-word payload is left alone, and the date string is untouched because it has no camelCase word in it.

Supported features

  • Each uppercase letter in a camelCase word starts a new segment: lastLoginAt → last_login_at.
  • Digits stay attached to the word they follow: base64Data → base64_data, address2Line → address2_line.
  • Works on any text, not just one name: object literals, SQL, YAML or a list with one name per line are all scanned in place.
  • The rest of the text (punctuation, indentation, values) is kept exactly as you pasted it.

Use cases

Sending a JS payload to a Python API

A FastAPI or Django REST endpoint usually declares user_id and created_at. Converting the request object built in the browser shows exactly which keys the backend model needs.

Writing a migration for fields that came from the frontend

When a form adds marketingOptIn and referralCode, the database columns are normally marketing_opt_in and referral_code. Paste the field list and use the result in your ALTER TABLE statement.

Notes and limitations

  • Consecutive capitals are treated as a single acronym: userID becomes user_id, homeURL becomes home_url, and parseHTTPServer becomes parse_http_server.
  • Text inside string literals and comments is converted too, and so are library calls such as getElementById. Paste only the part you actually want renamed.

FAQ

Will userID become user_id?

Yes. A run of capitals is read as one word and lowercased, so userID → user_id. The one case it cannot split is two acronyms written together, such as loadXMLHTTPData, which becomes load_xmlhttp_data.

Can I convert JSON keys but not the values?

Values are only changed if they themselves look like camelCase words. Numbers, dates and ordinary sentences stay as they are; a string value like "darkMode" would be converted, so check enum-like values.