CSV ↔ JSON Converter

Convert CSV to a JSON array of objects and back — quoted fields, semicolon and tab delimiters supported, all in your browser.

1,123 views

How the Conversion Actually Works

CSV and JSON model data differently, and the direction you convert in determines how much guesswork is involved. CSV → JSON is close to mechanical: the header row becomes the set of keys, and every following row becomes one object with those keys — name,age over Ada,36 becomes [{"name":"Ada","age":"36"}]. Quoted fields containing commas, escaped quotes ("") and multi-line cells are parsed per RFC 4180, and the delimiter (comma, semicolon or tab) is detected automatically from the first line.

JSON → CSV is where the real difficulty lives. CSV is strictly flat — one row, one record, one value per cell — while JSON naturally supports nesting: an object can contain another object or an array as a field's value, and there's no universally agreed way to squeeze that into a single CSV cell. Take {"name":"Ada","address":{"city":"London"}} — should the column be named address.city (dot-notation, flattening the nested object into extra columns), or should the entire address value be embedded as a raw JSON string in one cell, like {"city":"London"}? Both approaches are used in the wild and neither is "the" standard; this tool takes the dot-notation route for one level of nesting and falls back to embedding JSON text for arrays and deeper structures, because that keeps simple objects genuinely spreadsheet-friendly without silently losing data on complex ones.

Worth internalizing: this isn't a gap in the tool, it's a gap in the data model itself. Any CSV↔JSON converter you try — this one included — has to make an editorial call about flattening, because the two formats were never designed to be perfectly interchangeable. CSV was built for tabular ledgers; JSON was built for arbitrarily shaped documents. Knowing that up front explains why round-tripping a complex JSON file through CSV and back rarely reproduces the exact original structure, and why keeping deeply nested data in JSON form is often simply the right call rather than a limitation to work around.

What's Worth Knowing

  • CSV has no data types. Every value round-trips as text unless you enable number conversion, which turns numeric-looking strings into real JSON numbers (while leaving zero-padded IDs like "007" as strings, since converting those would corrupt them).
  • The delimiter is auto-detected, not assumed. Excel exports with semicolons in many European and Turkish locales, because the comma is already the decimal separator there — the parser checks the header row to pick the right one.
  • JSON → CSV unions all keys across objects. If some records have a field others don't, the header includes every key seen anywhere in the array, and missing ones are left blank in that row.
  • Nothing leaves your browser. Parsing and conversion both happen locally in JavaScript, so pasting a sensitive export doesn't send it anywhere.
  • Row order is preserved both ways. The first data row stays first after conversion in either direction, which matters when a spreadsheet or downstream script relies on positional order rather than an explicit sort key.

Frequently Asked Questions

Why are all my numbers strings?

CSV has no types — everything is text. Enable the "convert numbers" option to turn numeric-looking values into JSON numbers (IDs with leading zeros are kept as strings, since converting those would silently corrupt them).

My Excel CSV uses semicolons — will it work?

Yes — the delimiter is detected from the first row. Turkish and many European Excel locales export with semicolons because the comma is already the decimal separator there.

What about nested JSON?

CSV is flat: nested objects/arrays are serialized as JSON strings inside the cell, or flattened into dot-notation columns for shallow objects. For deeply nested data, flatten it first or keep it as JSON rather than forcing it through a spreadsheet.

Why doesn't this tool just pick one standard for flattening nested JSON?

Because there isn't one — different ecosystems genuinely disagree. Dot-notation columns (address.city) keep simple nesting spreadsheet-readable but multiply columns fast; embedding the nested value as a raw JSON string keeps one column per field but requires re-parsing that cell later. This tool uses dot-notation for shallow objects and falls back to embedded JSON text for arrays and deeper nesting.

What happens to an array inside an object during JSON → CSV?

It's serialized as JSON text inside a single cell rather than spread across columns — arrays can have any length, so there's no fixed number of columns to give them. Copy that cell's content and parse it separately if you need the individual items out.

Comments

No comments yet — be the first to write one!

Similar Tools