CSV and JSON are both extremely common ways to move structured data around, but they're shaped very differently — CSV is flat rows and columns, JSON is nested key-value objects. Converting between them sounds trivial until you hit a field with a comma in it, and suddenly the "just split on commas" approach falls apart.
Why Convert CSV to JSON
Spreadsheets, databases, and export tools speak CSV fluently, but most modern APIs, JavaScript code, and web applications expect JSON. Converting a CSV export into JSON turns each row into an object whose keys come from the header row — so a spreadsheet with columns name, email, age becomes an array of objects like {"name": "...", "email": "...", "age": "..."}, ready to hand to code that expects structured objects rather than raw rows.
How to Convert
- Open the CSV ⇄ JSON Converter.
- Paste your CSV data, including its header row.
- The tool parses each row into a JSON object keyed by the header row, and shows you the resulting JSON array.
- Copy the output, or switch direction to convert JSON back into CSV instead.
The Tricky Cases: Quotes and Commas
The CSV format has one rule that trips up naive parsers constantly: a field that itself contains a comma has to be wrapped in double quotes, like "Smith, John",42,"Toronto, ON". A correct parser has to recognize those quotes and treat the comma inside them as part of the data, not as a column separator — simply splitting the line on every comma would incorrectly break that one field into two columns. The same logic applies to fields containing the quote character itself, which get escaped as a doubled quote ("") inside the quoted field. A proper CSV parser (rather than a basic string split) handles all of this correctly.
Converting JSON Back to CSV
Going the other direction works best when the JSON is a flat array of objects with a consistent set of keys — those keys become the CSV header row, and each object's values become one row. JSON that's deeply nested (objects containing other objects, or arrays of arrays) doesn't have an obvious flat, tabular equivalent, so it typically needs to be flattened or restructured before it converts cleanly to rows and columns.
FAQ
What happens to numbers and booleans in a CSV field? Every value in a CSV file is plain text, with no built-in concept of numbers, booleans, or other data types. A CSV to JSON converter has to decide whether to keep everything as a JSON string or attempt to detect and convert values that look like numbers (e.g. "42") or booleans (e.g. "true") into their actual JSON types — check your specific tool's behavior, since this choice affects how the resulting JSON should be used downstream.
How are commas inside a CSV field handled? A properly formatted CSV file wraps any field containing a comma in double quotes, like "Smith, John" — the quotes signal that the comma inside is part of the data, not a column separator. A correct parser has to specifically look for and respect these quoted sections rather than naively splitting every line on every comma, or quoted fields would get incorrectly split into extra columns.
Can I convert JSON back to CSV? Yes, though it works best when the JSON is a flat array of objects that all share a similar set of keys — those keys become the CSV header row, and each object becomes one row. Deeply nested JSON (objects inside objects, or arrays of arrays) doesn't map cleanly to CSV's flat, tabular structure and typically needs to be flattened or restructured first.
What if my CSV doesn't have a header row? Without a header row, there are no field names to use as JSON object keys, so a converter typically either uses generic placeholder keys (like "column1", "column2") or outputs each row as a plain JSON array of values instead of an object with named fields. It's worth adding a header row to your source CSV if you specifically need named fields in the output.