CSV looks simple until a comma turns up inside a field. The table shows how each CSV feature becomes JSON.

How CSV features map to JSON

Per RFC 4180; page options can change it.
CSV feature JSON result Example
Header row Object keys “name” and “age”
Quoted field with a comma One string Stays one value
Empty cell null Blank becomes null
Plain number Number 42 stays 42
Dotted header Nested object Nests under address
No header row Array of arrays Each row becomes a list

CSV to JSON, step by step

CSV textParserJSON→→Split rows, respect quotes

Worked example: a three-row CSV with a comma inside a name

Start with this CSV: name,age, then “Smith, John”,34 and Lee,28. The quotes keep the comma inside the name from splitting the field, so row one parses to name “Smith, John” and age 34. The output is a JSON array of two objects: {“name”: “Smith, John”, “age”: 34} and {“name”: “Lee”, “age”: 28}. Note that 34 and 28 come out as numbers, not text.

Limitations

This converter runs entirely in your browser, which keeps your data private but limits very large files: a multi-megabyte CSV can slow the tab. It cannot guess intent either: dates stay as text, and numbers with leading zeroes (007, 01234) lose them when typed as numbers.

Sources

  • RFC 4180, Common Format and MIME Type for CSV Files (2005)
  • ECMA-404, The JSON Data Interchange Syntax (2017)

Learn more: CSV vs JSON Guide