fjordtools / Convert / CSV JSON
CSV ⇄ JSON Converter
Convert CSV to JSON and JSON to CSV in your browser. The delimiter is detected, quotes work, and errors name the row. Nothing is uploaded.
About CSV JSON
How do I convert CSV to JSON?
Paste the CSV and the JSON appears next to it. With Header row on, the first row names the fields and every other row becomes an object, so name,age followed by Ada,36 becomes [{"name": "Ada", "age": 36}]. Choose Arrays for one array per row. JSON → CSV goes the other way. It all runs in your browser.
Turn the header off when the file has none, and every row becomes an array. Going back to CSV, the columns are every key found in the objects, in the order they first appear, and a missing key or a null leaves an empty cell. A nested object or list is written into its cell as JSON text. The file is not uploaded. To tidy the result, use the JSON formatter; for config files there is the YAML, JSON and TOML converter.
What does Detect types do?
CSV has no types: every cell is text. With Detect types on, a cell becomes a number, true, false or null only when it is already written that way in JSON, and its text is kept as written. So 36 and 9.50 become numbers, but 007, 1,5, TRUE and an empty cell stay text, and a zip code keeps its leading zero. A number with more than 15 digits also stays text, because many programs round such numbers when they read JSON: 12345678901234567890 would come back as 12345678901234567000. Turn Detect types off when every cell must stay a string, for example phone numbers.
Delimiters and quotes
Auto picks comma, semicolon, tab or pipe by looking for the one that splits the first rows into the same number of fields; the input label shows which one it used. Choose one yourself when a file is ambiguous. A field that contains the delimiter, a quote or a line break is wrapped in double quotes, and a quote inside it is written twice, as RFC 4180 describes: "say ""hi""" reads as say "hi". A quote that is never closed, or a row with more or fewer fields than the first row, stops the conversion with the row and line, so no row is silently shifted. Blank lines are skipped, and a byte order mark at the start of the file is removed.
If you landed here from an error
- CSV: quoted field is never closedA value opened with a quote and the file ended before the closing quote.
- CSV: row has a different number of fieldsA row has more or fewer values than the header. Usually an unquoted comma.
- CSV: text after a closing quoteA quoted value ended and something other than a delimiter followed.
Related tools
- JSON FormatterFormat, validate, minify and sort JSON.
- YAML JSON TOMLConvert config files between YAML, JSON and TOML.
- Text DiffCompare two texts or JSON documents line by line.
- SQL FormatterFormat SQL queries with clean clauses and keyword case.
- Base64Encode and decode text, with URL-safe and UTF-8 support.
- URL EncoderPercent-encode, decode and take apart URLs and query strings.