Skip to content

CSV to JSON Converter

Paste CSV and get a JSON array of objects keyed by your header row, or an array of arrays if there is no header. Switch the direction to turn a JSON array of flat objects back into CSV. Quoted commas, doubled quotes and line breaks inside fields are read correctly, and the conversion runs in your browser. Free, no sign-up.

Direction

How to Use the CSV to JSON Converter

  1. 1. Choose a direction. CSV → JSON is the default; JSON → CSV expects a JSON array of flat objects.
  2. 2. Set the options. The delimiter can be auto-detected or fixed to comma, semicolon or tab; for JSON → CSV, Auto-detect writes commas. For CSV → JSON you also choose a 2-space, 4-space or tab indent and whether the first row holds headers.
  3. 3. Paste and convert. Press Convert. Problems — an unclosed quote, invalid JSON, an array that isn't made of objects — appear as a message instead of output.
  4. 4. Copy or download. Copy Result copies the output; the download button saves it as data.json or data.csv.

How the CSV Is Read

CSV looks simple and isn't: the same file can use commas, semicolons or tabs, and a field may contain the very character that separates fields. The closest thing to a specification is RFC 4180, which is informational rather than a standard. It says a field containing a comma, a double quote or a line break must be enclosed in double quotes, and that a double quote inside such a field is written as two. The converter follows those rules and adds some leniency:

  • Quoted fields. A field that starts with a double quote runs to the closing quote, so it can hold delimiters, line breaks and "" for a literal quote. A quote that is never closed stops the conversion and reports the line it started on.
  • Line endings. LF, CRLF and a bare CR all end a row, and blank lines are skipped.
  • Delimiter detection. In auto mode the converter looks only at the first line and picks whichever of comma, semicolon or tab appears most often; a tie goes to the comma. If the file's first line is unusual — a single column, say, or a title row — choose the delimiter yourself. RFC 4180 itself only knows commas; semicolons are common in files exported from spreadsheets set to European locales.
  • Everything is text. The converter does not guess types, so 2020 becomes the string "2020", not a number, and an empty cell becomes "", not null. Convert types afterwards if your code needs them.

Worked Example

Header

name,note,year

Row 1

"Smith, Jane","Said ""hello""",2020

Row 2

Lee,short

Result

Two objects. Smith, Jane has the note Said "hello" and the year "2020"; Lee has the note short and the year "".

The comma inside Smith, Jane stays in one field because of the quotes, and the doubled quotes collapse to one. Lee's row is one cell short, so the missing year becomes an empty string; a row with extra cells loses the extras, because there is no header to name them. Untick First row is headers and the same input becomes an array of arrays — [["name","note","year"],…] — with short rows left short.

Duplicate header names collide: with two columns called id, the later one wins and the earlier is lost, so rename one first.

Going Back: JSON to CSV

The reverse direction expects a top-level array whose items are all objects. The header row is the union of every key in order of first appearance, so objects with different keys still line up, and a missing value is left empty. Numbers and booleans are written as they appear, null becomes an empty cell, and any nested array or object is written into its cell as JSON text and quoted. If your data is nested, flatten it first. Cells containing the delimiter, a quote or a line break are quoted, with quotes doubled, and rows are joined with plain line feeds.

Applied to [{"name":"Smith, Jane","year":2020,"tags":["a","b"]},{"name":"Doe","note":"two\nlines","year":null}], the converter writes the header name,year,tags,note, a first row of "Smith, Jane", 2020 and the quoted text ["a","b"], and a second row for Doe whose year and tags are empty and whose note is the quoted two-line text.

Which Tool Do You Need?

You want toUse
Convert between CSV and a JSON arrayThis page
See CSV as a table to copy as HTMLCSV to Table
Make a Markdown table from CSVMarkdown Table Generator
Keep only some columns of a CSVColumn Extractor
Check or reformat the JSON itselfJSON Formatter
Convert YAML or XML to and from JSONYAML to JSON, XML to JSON
Typeset CSV for a paperLaTeX Table Generator, APA Table Generator

Frequently Asked Questions

How do I convert CSV to JSON?
Paste the CSV into the box, leave CSV → JSON selected and press Convert. With First row is headers ticked you get an array of objects keyed by the header names; without it you get an array of arrays. Copy the result or download it as data.json.
Does the converter handle quoted fields with commas or line breaks?
Yes. A field wrapped in double quotes can contain the delimiter, line breaks and doubled quotes, as RFC 4180 describes. An opening quote with no closing quote stops the conversion and names the line where the field began.
Which delimiters are supported?
Comma, semicolon and tab, either auto-detected from the first line or chosen by hand. Pipe-separated and other delimiters are not supported; a column extractor or find-and-replace pass can swap them for commas first.
Why are my numbers strings in the JSON?
CSV has no types, and the converter does not guess them, so every value comes out as a string and an empty cell as an empty string. That keeps values like 007 or 1e5 exactly as written; convert types in your own code where you need numbers.
How does JSON to CSV work?
It needs a JSON array of objects. Each object becomes a row, the columns are all the keys that appear anywhere, and nested objects or arrays are written into their cell as JSON text. Invalid JSON is reported with a line number when your browser's parser gives a position.
Why does my CSV open wrongly in Excel after converting?
The file is plain UTF-8 without a byte-order mark and uses the delimiter you chose, so Excel in a region that expects semicolons may put everything in one column, and non-English characters may need the import wizard set to UTF-8. Choosing the semicolon delimiter often fixes the first problem.
Is my data uploaded anywhere?
No. Both directions run in your browser, and the text you paste is not sent to CitationEasy. The download is generated locally.

Related Tools

More in Data, Markup & Code

See all Data, Markup & Code