Skip to content
MtrXTools

CSV to/from JSON

Convert CSV to JSON and back, with quoted and multiline cells, any delimiter and an optional header row. Values stay text by default, so leading zeros in IDs, postcodes and phone numbers survive. Runs in your browser.

Last updated

What it does

  • CSV to JSON: turns each row into an object keyed by the header row, or into an array when there is no header. Handles quoted fields, commas and line breaks inside quotes, "" for a quote, a byte-order mark and Windows line endings.
  • Detects the delimiter (comma, semicolon, tab or pipe) from the first lines, so data copied from a spreadsheet or exported in a European locale just works.
  • Keeps values as text by default, so 007, postcodes such as 01234 and phone numbers keep their leading zeros. Turn on number detection to get numbers and true/false where that is safe; values with leading zeros stay text either way.
  • JSON to CSV: writes an array of objects as a table, with a column for every key seen. Nested objects become dotted columns such as address.city, and arrays inside a row are written as JSON text.

Common CSV problems

A quoted field that never closes swallows the rest of the file. The converter reports the line where the quote opened, which is usually a stray " inside an unquoted field. Inside a quoted field, write a quote as "".

Rows with more or fewer cells than the header are kept: missing cells are empty, and extra cells get their own columnN names. Duplicate header names are numbered so no value is lost.

Questions

Why are my numbers strings in the JSON?
Because CSV has no types, and guessing breaks IDs, postcodes and phone numbers. Turn on "Detect numbers and true/false" if you want numbers; anything with a leading zero or a plus sign stays text.
Will Excel open the CSV correctly?
Yes. Fields that contain the delimiter, quotes or line breaks are quoted. If Excel in your locale expects semicolons, choose Semicolon as the delimiter.
Is there a size limit?
Only your browser's memory. Files of a few megabytes convert instantly; nothing is uploaded.