← All guides

How to Convert CSV to JSON (and Back)

CSV is how spreadsheets store data; JSON is how apps and APIs store it. Learn how the two formats map to each other, what breaks in conversion, and how to convert them free in your browser.

By Ernzi Tools team · November 7, 2026

CSV and JSON are the two formats that data lives in most of the time. CSV is the format of spreadsheets: rows and columns, simple and universal. JSON is the format of apps and APIs: structured, nested, and machine-readable. Sooner or later, data needs to move from one world to the other — a spreadsheet exported for an app, or an API response opened in Excel. The conversion is straightforward once you understand how the two formats map to each other, and where they can break.

CSV: rows and columns

A CSV file is exactly what it sounds like: comma-separated values. Each line is a row, each comma separates a column, and the first line usually holds the column names. It is the simplest data format in common use, which is why every spreadsheet program can read and write it. Its simplicity is also its limitation: a CSV has no notion of data types — everything is text — and it cannot represent nested structures. A column that holds a list, or a row that contains another table, has no natural place in a CSV. Quoting rules add a wrinkle: if a value itself contains a comma, it must be wrapped in quotes, and a quote inside a quoted value is doubled. Most of the time you never notice this, because your spreadsheet handles it — but it is the first thing that breaks a naive conversion.

JSON: structured and nested

JSON (JavaScript Object Notation) stores data as objects and arrays. A row of a spreadsheet becomes an object with named fields, and a whole table becomes an array of those objects. Unlike CSV, JSON knows data types: numbers are numbers, true and false are booleans, and null is distinct from an empty string. It also handles nesting naturally — an object can contain another object, or an array of objects. That makes JSON the format of APIs, configuration files, and anything where data has structure. Its cost is verbosity: the field names repeat on every row, so a JSON file is usually larger than the same data as a CSV, and it is harder to skim in a text editor.

How the conversion works

Converting CSV to JSON is mostly mechanical: the header row becomes the field names, and each subsequent row becomes an object with those fields. A three-column CSV with a hundred rows becomes an array of a hundred objects, each with three fields. Going the other way — JSON to CSV — the converter collects the field names from the objects, writes them as the header row, and then writes one row per object. The tricky parts are the edges: JSON objects with nested objects or arrays have no direct CSV equivalent, so converters either flatten them (turning an address object into separate columns) or stringify them into a single cell. Missing fields in some rows become empty cells. And data types are a judgment call: a good converter turns "42" into the number 42 and "true" into a boolean, while a careless one leaves everything as text.

Step by step: convert CSV to JSON

  1. Open the CSV file in a text editor or spreadsheet and check the header row: are the column names clean, without spaces or duplicates? Clean headers make clean JSON field names.
  2. Check for the usual traps: commas inside values (they must be quoted), inconsistent quoting, and empty lines at the end of the file.
  3. Open the CSV to JSON converter and drop in your file. Your data stays on your device; nothing is uploaded.
  4. Review the output. Check that numbers came out as numbers, that dates look right, and that no field is missing or misaligned. A quick way to check is to count: the number of JSON objects should equal the number of data rows in the CSV.
  5. If the JSON will feed an app or API, validate it with a JSON validator and pretty-print it so it is readable.

What breaks in conversion

  • Commas and quotes in values: a value like "Smith, John" must be quoted in CSV; if it is not, the converter splits it into two columns and every field after it shifts.
  • Different delimiters: some CSV files use semicolons or tabs instead of commas, usually because the data contains commas. The converter needs to know the delimiter.
  • Nested data: a JSON object with nested arrays cannot become a flat CSV without flattening or losing structure.
  • Dates and numbers: CSV stores everything as text, so "2026-01-05" and "01/05/2026" are different strings. Decide the format before converting.
  • Encoding: a CSV saved with the wrong character encoding turns accented characters and non-Latin scripts into gibberish. UTF-8 is the safe choice.

When to use which format

Use CSV when the data is a flat table and a human needs to open it in a spreadsheet: exports, reports, mailing lists, and anything that will be edited by hand. Use JSON when the data has structure or will be consumed by software: API responses, configuration, application data, and anything with nested fields. The conversion between them is a translation, not a transformation — the data is the same, only the packaging changes. And because both formats are plain text, the conversion is exact when the structure is clean: nothing is lost, and the round trip (CSV to JSON and back) should give you back the table you started with.

Data moves between spreadsheets and apps every day, and CSV and JSON are the two languages it speaks. Learn how they map to each other, watch out for commas and nesting, and the conversion takes seconds — with the data intact on both sides.

Try these tools
CSV to JSONJSON to CSVJSON Prettify

All tools are free and run entirely in your browser — your files never leave your device.