How do I turn spreadsheet column headers like Product Name into snake_case keys for code or an API?

Copy the header row, paste it into the case converter one header per line, and choose snake_case: each line becomes lower-case words joined by underscores, with symbols such as brackets dropped. Product Name becomes product_name and Price (SAR) becomes price_sar. If your JSON uses keys like productName, choose camelCase instead.

Published · 3 min read

An example from a product file

Three column headers as they come out of a typical export: Product Name, Price (SAR) and Stock Qty. These are the tool's results for each programmer case:

  • snake_case: product_name, price_sar, stock_qty.
  • camelCase: productName, priceSar, stockQty.
  • kebab-case: product-name, price-sar, stock-qty.

Look at what happened to the brackets in Price (SAR): they were dropped completely and the two words remained. The tool splits each line into words at spaces and punctuation, then joins them with the separator you picked.

Which case should I pick?

There is no single right answer; what counts is what the other side expects. Database columns and Python code usually use snake_case. JSON keys in JavaScript apps often use camelCase. kebab-case suits file names and URL parts better than keys, because a hyphen is not allowed in variable names in most languages. If the platform you integrate with has API documentation, copy its style exactly.

Headers that need a second look

Four harder headers, Customer's Email, VAT %, SKU / Barcode and the Arabic «اسم المنتج», came out in snake_case as:

  • customers_email: the apostrophe was removed, so the s joined the word.
  • vat: the % sign was dropped like every other symbol, so the fact that the column is a rate is lost. Name it vat_rate or vat_percent yourself.
  • sku_barcode: the slash was dropped and both words kept.
  • اسم_المنتج: Arabic letters stay as words but have no case, so they are simply joined with an underscore. Most code expects Latin keys, so write an English header instead.

The tool also finds word boundaries inside compound words: productName becomes product_name, and HTTPServer becomes http_server. That helps when converting existing camelCase keys to snake_case.

Steps

  1. Copy the header row from your sheet. If it pastes across one line, transpose it into a column first so each header sits on its own line.
  2. Paste into the Text case converter and choose snake_case or camelCase under «Target case».
  3. Review headers that contain symbols or Arabic and adjust them by hand.
  4. Copy the result into your code or into the new header row.

Next step: from sheet to JSON

If the goal is to turn the whole product file into JSON for an API, rename the header row first, then convert the file in the CSV and JSON converter. Column headers become the object keys as they are, so they should already be in the style the other system expects before you convert.

Common questions

Do the programmer cases work line by line?

Yes. Each line is converted on its own and an empty line stays empty, so the number and order of lines never change.

Why is there no «Characters changed» count for these cases?

Because the conversion drops symbols and adds separators, so characters cannot be compared one to one. The tool shows how many lines changed instead.