Converters

CSV / JSON Converter

Convert between CSV and JSON arrays with quoted fields, newlines, and custom delimiters.

CSV / JSON
Supports quoted fields, escaped quotes, and embedded newlines.
Converted output
—

CSV / JSON Conversion

Convert between CSV table data and JSON arrays with support for quoted fields, escaped quotes, embedded newlines, and common delimiters.

Data Rules

  • CSV can use its first row as object keys
  • JSON input must have an array root
  • CSV does not retain number or boolean types, so parsed fields are strings by default

A two-way converter between CSV text and JSON arrays: it parses comma-, semicolon-, tab- or pipe-separated data into a JSON array, and writes a JSON array back out as CSV with RFC 4180 quoting. Useful for turning spreadsheet and database exports into fixtures or API payloads, and for handing JSON records to Excel.

CSV has no types, so every parsed cell stays a string

Nothing in RFC 4180 separates the number 1 from the text 1, and this direction makes no attempt to guess: Papa.parse output is passed straight to JSON.stringify, so a cell reading "007" stays "007", true stays "true", and "1.50" keeps its trailing zero. That is the safe default for postal codes, phone numbers and account numbers, which are identifiers rather than quantities and lose meaning when coerced to numbers. The other direction behaves differently because JSON itself carries types — the number 1 is written as 1 and the boolean true as true, both unquoted — so a round trip keeps the text but drops the type. Cast on the JSON side afterwards, and never treat a converted boolean as trustworthy.

When a field needs quotes, and why one bad quote erases the result

RFC 4180 requires double quotes around any field containing the delimiter, a double quote, CR or LF, and writes a literal quote as two adjacent quotes. The writer here also quotes values with a leading or trailing space, because unquoted padding gets trimmed by some readers, while a field that merely contains commas in a semicolon-delimited file is left bare. The reader is less forgiving: an unterminated quote raises a MissingQuotes error, and because this tool refuses to show partial results, any entry in the error list suppresses the output entirely. Up to five errors are printed with their code and one-based row number, so a MissingQuotes warning at row 2 usually means one quote pair was lost while copying out of Excel.

Why JSON records can produce ragged CSV columns

For an array of objects the header is the union of every key ordered by first appearance, and each record is rebuilt against that list, so a record missing a key yields an empty cell rather than a shifted row; null becomes an empty cell too. Non-scalar values are serialised with JSON.stringify first and then escaped as CSV, which means an array of two tags arrives as one cell holding quoted JSON text — the only way CSV can carry nesting. An array of scalars instead collapses into a single column literally named value. Column order follows discovery rather than sorting, so a key that appears only in an early record still claims an early column, and a later record with a different key appends a new column at the end.

Worked example

Nested values and a missing key, written out as CSV

Input
[{"id":1,"name":"Ada","tags":["api","cli"]},{"id":2,"name":"Lin"}]
Output
id,name,tags
1,Ada,"[""api"",""cli""]"
2,Lin,

Both records are rebuilt against the union of keys, so the second row ends with an empty tags cell instead of losing a column. The tags array is not spread across columns: it is stringified as JSON and then quoted per RFC 4180, which is why the cell reads as escaped JSON. Lines are joined with LF and the output has no trailing newline.

Limits and pitfalls

  • Only four delimiters are offered — comma, semicolon, tab and pipe — and the quote character is always a double quote, so backslash escaping or single-quote quoting cannot be described.
  • The CSV-to-JSON direction never infers types: "007" and "1.50" arrive as strings, so cast the values you need on the JSON side of the conversion.
  • A row shorter than the header produces no key at all, since the missing value is undefined and JSON.stringify drops it, while surplus cells are collected into a __parsed_extra array.
  • Any parser error suppresses the output completely, so one unterminated quote blocks the whole file, and only the first five errors are reported.
  • Duplicate headers are silently renamed to a, a_1, a_2 and an empty header cell becomes a key with an empty name, neither of which raises an error.

Related tools

Choosing between this page, jq, json-lines and a spreadsheet for the same table

Situationcsv-json hereReal alternative
A cell has to hold a list or an objectFlat tables only. A nested value is serialised into one quoted cell, so it survives the trip as text and needs a second parse on the other side.The json-lines tool keeps one record per line with arrays and objects intact; a feed with nested fields belongs there, not in a CSV column.
The export cannot be pasted into a tabThere is no file input: the entire document has to sit in one textarea, so a dump that lives on disk is out of reach.jq with @csv, or ten lines of Python around csv.DictReader, reads straight from a path without copying anything into a browser.
Nothing needs converting, only checkingCSV to JSON always re-serialises with a two-space indent, and a JSON root that is not an array is rejected before anything is written.The json-format tool parses the same text, accepts any root value and lets you pick the indent width; keep it when the payload is meant to stay JSON.
A comma sits inside an unquoted source fieldOne surplus field raises TooManyFields and the whole output is suppressed — this page will not guess where the split belongs.Repair the producer instead: export with quoting enabled, or dump tab-separated. Ten lines of Python csv.writer re-quote that column correctly.
A Windows macro downstream insists on CRLF and semicolonsRecords are joined with a bare LF and the delimiter is written exactly as selected, so there is no line-ending switch to flip.Excel writes CRLF on save and uses semicolons on comma-decimal locales; round-trip through it, or run unix2dos, when a legacy importer is the consumer.

One concrete scenario

A 4,001-line export where 400 stray commas blank the result

Postgres hands you a catalogue dump of 4,001 lines: one header plus 4,000 product rows with id, name and description. The dump was assembled by joining values with commas, so the 400 descriptions that contain a comma arrive unquoted, and those rows carry four fields where the header declares three. Paste it in with the delimiter on comma and the header box ticked: all 400 rows raise TooManyFields, the panel prints five of them, and the output stays empty — the 3,600 clean rows disappear with them. Switch the delimiter to semicolon and the same text parses as 4,000 rows across 3 fields, provided no description contains a semicolon. Search for ; first, and re-export with quotes if a hit turns up.

Frequently Asked Questions

Is the first CSV row always a header?
No — it is a convention, not part of the format. This tool has a switch: on, the first row becomes the JSON object keys; off, you get an array of arrays. Remember to turn it off for header-less exports (common in bank and carrier statements).
How are commas and newlines inside fields handled?
This is CSV’s one complicated rule: fields containing commas, quotes, or newlines are wrapped in double quotes, and embedded quotes are doubled (""). Excel exports normally follow this, but Chinese Excel defaults to GBK encoding and may use semicolons or tabs — check the delimiter option before pasting.
Numbers become strings — how do I keep types?
CSV has no types: "123" could be a quantity or an ID. The tool offers type inference (pure numbers become numbers, true/false become booleans); off, everything stays a string. For precise typing, post-process on the JSON side.

Content reviewed: