Developer Tools • 4 min read

How to Convert CSV to JSON (and Back) Without Breaking Your Data

Turn a spreadsheet export into a JSON array and back, keep IDs and leading zeros intact, handle quoted commas, and validate the result before you import it.

Published: 2026-11-26 • Last Updated: 2026-11-26 • By Mohammed Zawwar Hussain

Interactive Online Tools Referenced in this Guide

What the conversion does

CSV to JSON Converter turns each row of a CSV file into a JSON object, using the header row as the keys:

id,product,price
101,Pro Laptop,1299.99

→ [{"id": "101", "product": "Pro Laptop", "price": "1299.99"}]

It also works the other way: a JSON array of objects becomes CSV that opens in Excel or Google Sheets, with the columns taken from the keys of the first object. Conversion runs in your browser; paste the data or load a .csv or .json file. Empty cells in a CSV row become empty strings ("") in JSON rather than null, so your downstream code can always expect string values for every column present in the header row.

Step by step

  1. In Excel, save the sheet as CSV UTF-8 (Comma delimited) (File → Save As). The converter reads plain CSV, not .xlsx, and UTF-8 keeps Arabic, Spanish and accented letters intact instead of turning them into question marks.
  2. Make sure the first row holds unique column names with no blank trailing rows below your data. Column names become your JSON keys, so short names without spaces (unit_price rather than Unit Price (SAR)) are much easier to use in code.
  3. Choose CSV to JSON, paste or load the file, and copy or download the result.
  4. Paste the output into JSON Formatter & Validator to confirm it is valid JSON, check the array length against your spreadsheet row count, and read it comfortably.

Why every value is a string

CSV has no data types: 00123, 1299.99 and TRUE are all just text. The converter keeps every value as a string on purpose, because guessing would damage data that only looks numeric:

  • Postal codes, product codes and employee IDs such as 00123 would lose their leading zeros.
  • Phone numbers like +966500000000 could turn into numbers in scientific notation.
  • Long account numbers would lose precision beyond about 15 digits.

Convert the fields that really are numbers in your own code, where you know which ones they are. For example, parse price with Number(row.price) after checking for empty strings, while leaving id, sku and postal_code as strings so formatting and leading zeros never change. Booleans and dates follow the same rule: normalize "TRUE", "true" or "1" explicitly in your importer instead of relying on automatic type guessing.

Quotes, commas and other traps

In your CSVWhat happensWhat to do
"Riyadh, KSA"Stays one field, because it is quotedNothing
"He said ""hi"""Doubled quotes become one quoteNothing
Semicolons between fields (common in Europe)Not split, since fields are separated by commasReplace the semicolons with commas first, or export with a comma delimiter
A line break inside a quoted cellNot supported; each line is treated as a rowRemove line breaks in that column before exporting
Duplicate column names in the header rowLater columns overwrite earlier ones with the same keyRename duplicate headers before converting
Blank trailing rows from a spreadsheetProduces empty objects with blank string valuesDelete empty rows below your table before saving CSV

Going from JSON back to CSV

Choose JSON to CSV and paste a JSON array of objects (wrapped in square brackets [...]). The columns come from the keys of the first object, so if later objects have extra keys, put an object with every key first, or add the missing keys with empty values.

Nested objects and arrays do not map cleanly to flat spreadsheet columns: an address object like {"address": {"city": "Riyadh"}} will serialize as [object Object] or a raw string unless you flatten it first into top-level keys such as address_city. Do that flattening in your script or API export before converting to CSV, and verify that any fields containing commas or quotes look right when opened in Excel or Google Sheets.

Before you import the JSON

Before sending converted JSON into an API, database seed script or analytics pipeline, run two quick checks:

  • Check the shape: Describe what your importer expects with JSON Schema Generator: paste a sample object and it creates a Draft 7 schema you can use to validate future files and catch missing required fields early.
  • Check edge rows: Inspect the first row, the last row and any row that had commas, quotes or non-Latin characters in the original sheet.
  • Config vs. data: If you are converting settings or deployment manifests rather than spreadsheet rows, YAML to JSON Converter handles the YAML files many developer tools use.

Frequently Asked Questions

Can I convert an Excel file directly? ↓
Save the sheet as CSV (UTF-8) in Excel first, then convert the CSV.
Why are my numbers in quotes? ↓
CSV has no data types, so every value is kept as text to avoid changing IDs, phone numbers or codes. Convert real numbers in your own code.
Is my data uploaded? ↓
No. The conversion happens in your browser, so sensitive exports, customer lists, and internal spreadsheets stay on your own device.