CSV to JSON

Convert CSV data to a JSON array of objects. First row is treated as the header.

Comma (,)
Semicolon (;)
Tab
Pipe (|)
Yes
No
2 spaces
4 spaces
Minified
Converted 2 rows

Converting spreadsheet data to JSON

CSV is the universal export format of spreadsheets and databases; JSON is the universal format of APIs and applications. Converting between them is one of the most common data-wrangling tasks there is.

The conversion takes the first row as field names and turns every subsequent row into an object, producing an array of objects - the shape almost every API and JavaScript application expects.

Key takeaways

  • The first row becomes the object keys.
  • Fields containing commas, quotes or newlines must be quoted in the CSV.
  • A doubled quote inside a quoted field represents one literal quote.
  • Everything in CSV is a string - type information is lost on export.
  • Regional settings mean some spreadsheets export semicolons rather than commas.

How the conversion works

CSV input:
name,age,city
Ada,36,London
Grace,45,New York

JSON output:
[
  {"name": "Ada", "age": "36", "city": "London"},
  {"name": "Grace", "age": "45", "city": "New York"}
]

Why CSV parsing is harder than splitting on commas

The naive approach - split each line on commas - breaks on real data almost immediately. CSV has quoting rules that exist precisely because the delimiter can appear inside the data.

CSVCorrect interpretationNaive split gives
a,b,cThree fieldsCorrect
"Smith, John",42Two fieldsThree fields - wrong
"She said ""hi""",1Two fields, one containing a quoteMangled
"line one line two",2Two fields, one with a newlineTwo broken rows
a,,cThree fields, middle emptyCorrect

A proper parser tracks whether it is inside a quoted field, which is the only way to handle delimiters and newlines appearing within data.

The quoting rules in brief. A field must be quoted if it contains the delimiter, a double quote, or a line break. Inside a quoted field, a literal double quote is written as two consecutive double quotes. These rules come from RFC 4180, which is the nearest thing CSV has to a specification.

Delimiters and regional settings

DelimiterNameWhere you meet it
,CommaThe default in most English-locale exports
;SemicolonEuropean locales where comma is the decimal separator
\tTabTSV files; safest for data containing commas
|PipeCommon in data warehousing

A spreadsheet set to a European locale exports semicolon-separated files by default, because a comma there means a decimal point. This is a very common source of "the file will not import" problems.

Type conversion

CSV has no type system - every field is text. When converting to JSON you have to decide whether to preserve that or infer types, and both choices have costs.

CSV valueAs a stringType-inferredRisk of inferring
42"42"42None usually
007"007"7Loses leading zeros in ID codes
true"true"trueA literal word "true" becomes a boolean
+44 20 7946"+44 20 7946"Could become a numberPhone numbers corrupted
2026-09-14"2026-09-14"Could become a dateTimezone shifts appear
1.50"1.50"1.5Trailing zero lost on prices

This converter keeps values as strings, which is lossless. Convert types deliberately afterwards, where you know what each column actually means.

The leading zero problem is a real-world classic. Postcodes, product SKUs, phone numbers and account IDs frequently begin with zeros. Any tool that infers types will strip them, silently corrupting every affected record. Spreadsheets do this on import too, which is why so many exported datasets have damaged identifier columns.

Other things that go wrong

  • Encoding. A file saved as Windows-1252 rather than UTF-8 turns accented characters into mojibake. Always export and read as UTF-8.
  • Byte order marks attach themselves to the first column name, giving you a key like "\ufeffname" that never matches.
  • Duplicate column names collapse into one key, silently losing a column.
  • Inconsistent column counts between rows, usually from unescaped delimiters in the data.
  • Line ending differences - CRLF versus LF - can leave a stray carriage return at the end of the last field on every row.
  • Empty trailing lines produce an empty final object.
Everything runs in your browser. Your data is processed entirely on your own device - nothing is uploaded, logged or stored. That matters when the payload you are debugging contains customer records, API responses or anything else you should not be pasting into a remote service.

Frequently Asked Questions

How do I convert CSV to JSON?

Paste your CSV into the tool. The first row is taken as field names and every subsequent row becomes an object, producing an array of objects - the shape most APIs and JavaScript applications expect.

Does it handle commas inside fields?

Yes. Fields containing the delimiter must be wrapped in double quotes in the CSV, and the parser tracks quoted state correctly. This is why a naive split on commas fails on real data - "Smith, John" is one field, not two.

How are quotes inside a field represented?

A literal double quote inside a quoted field is written as two consecutive double quotes. So "She said ""hi""" is a single field containing: She said "hi". This is the RFC 4180 convention.

Why does my CSV use semicolons instead of commas?

Because it was exported from a spreadsheet set to a European locale, where the comma is the decimal separator. Those locales use semicolons as the field delimiter instead. Set the delimiter option to match your file.

Are numbers converted to JSON numbers?

No, values are kept as strings, which is lossless. Automatic type inference corrupts data - it strips leading zeros from postcodes and SKUs, mangles phone numbers and drops trailing zeros from prices. Convert types deliberately afterwards where you know what each column means.

Why do my accented characters look wrong?

Almost certainly an encoding mismatch - the file was saved as Windows-1252 or Latin-1 rather than UTF-8. Re-export it as UTF-8. This is the usual cause of names appearing with strange character sequences.

Can a CSV field contain a line break?

Yes, provided the field is quoted. A proper parser handles this correctly, keeping the multi-line content as a single field. Tools that split the file on newlines before parsing break badly on such data.

Is my data uploaded anywhere?

No. Conversion runs entirely in your browser. Nothing is transmitted or stored, which matters when the spreadsheet contains customer records or other confidential data.

Related Calculators