Skip to content
Case Converter Online
en

CSV to JSON Converter

Paste CSV or open a .csv file and get a JSON array as you type. The delimiter is detected for you, and you can convert JSON back to CSV too.

Paste CSV or press Sample. Your data stays in your browser.

What this converter does

CSV is the common export format of spreadsheets and databases: one record per line, values separated by commas. JSON is what most APIs, JavaScript code and NoSQL databases expect. This tool turns one into the other.

With a header row, each line of the CSV becomes a JSON object, and the column names become the keys. Without a header row, each line becomes an array of values. Parsing is done by Papa Parse, a well tested CSV library that handles quoted fields, commas inside quotes and line breaks inside cells.

How to use it

  1. Choose CSV to JSON (or JSON to CSV for the other direction).
  2. Paste your data, press Open file to load a .csv or .tsv file, or press Sample.
  3. Set the options. The JSON updates as you change them:
    • Delimiter: Detect, Comma, Semicolon, Tab or Pipe.
    • Output: 2 spaces, 4 spaces or Minified.
    • First row is header: objects with named keys when on, arrays when off.
    • Convert numbers and true/false: turns 12 into a number and true into a boolean. When off, every value stays a string.
    • Skip empty lines: ignores blank rows, which spreadsheets often add at the end.
  4. Press Copy or Download to save the result as a .json file.

The status line shows how many rows and columns were read and which delimiter was detected.

Example

This CSV, with a quoted name that contains a comma:

id,name,email,city,signup_date,active,orders
1,Ada Lovelace,[email protected],London,2024-03-01,true,12
2,"Hopper, Grace",[email protected],New York,2024-04-17,false,3

becomes:

[
  {
    "id": 1,
    "name": "Ada Lovelace",
    "email": "[email protected]",
    "city": "London",
    "signup_date": "2024-03-01",
    "active": true,
    "orders": 12
  },
  {
    "id": 2,
    "name": "Hopper, Grace",
    "email": "[email protected]",
    "city": "New York",
    "signup_date": "2024-04-17",
    "active": false,
    "orders": 3
  }
]

The quotes around “Hopper, Grace” kept the comma inside the name. The ids and order counts became numbers, true and false became booleans, and the dates stayed strings because JSON has no date type.

Values that stay text

Turning every number-like value into a number can damage data. This converter keeps a value as text when converting it would change it:

[
  {
    "name": "Ada",
    "zip": "02134",
    "phone": "0207 946 0000"
  }
]

The zip code keeps its leading zero. The same rule applies to IDs with leading zeros and to integers longer than JavaScript can store exactly. A price written with a decimal comma, such as 2,50 in a semicolon file, also stays a string, because it is not a valid JSON number.

JSON to CSV

Press JSON to CSV and paste an array of objects. Every key that appears in any object becomes a column, in the order they first appear. With Flatten nested objects on, nested data gets dotted column names:

id,name,address.city,address.zip,tags
1,Ada,London,NW1,"[""admin"",""dev""]"
2,Grace,New York,,

Grace had no zip code, so that cell is empty. The tags array was written as JSON text, with its quotes doubled as the CSV format requires. An array of arrays is written row by row without a header. Press Download to save it as a .csv file that Excel, Numbers and Google Sheets can open.

When rows do not fit

If a row has more or fewer values than the header, the converter still produces JSON and points to the problem by spreadsheet row number, for example “Row 3: Too many fields: expected 2 fields but parsed 3”. Row 1 is the header. A quote that is opened and never closed is reported the same way. Fix the row in your file and paste it again.

Tips

  • Check the JSON with the JSON formatter, which can also sort keys and minify.
  • Need YAML for a config file? Convert to JSON here, then use the JSON to YAML converter.
  • To show the data in a README, the Markdown table generator accepts the same CSV or spreadsheet cells.
  • Turn Convert numbers and true/false off when every value must stay a string, for example before importing into a system that does its own typing.

Other ways to convert CSV to JSON

  • Python: the built-in csv module’s DictReader reads rows as dictionaries, and json.dump writes them out.
  • csvkit: the csvjson command converts a CSV file to JSON in a terminal.
  • Excel and Google Sheets have no JSON export. Save as CSV first, then convert it here.
  • jq can work the other way, from JSON to CSV, with its @csv filter.

Everything happens in your browser. Large files take a little longer, and nothing is uploaded.

CSV to JSON: questions and answers

Why does my zip code still have quotes in the JSON?

On purpose. A value like 02134 would lose its leading zero as a number, so values with leading zeros stay as text. The same goes for whole numbers too large to store exactly, such as long IDs. Ordinary numbers like 12 or 3.5 become JSON numbers.

My file uses semicolons. Will it work?

Yes. With Delimiter set to Detect, the converter checks for commas, semicolons, tabs and pipes and picks the one that fits. Spreadsheets in many European locales save CSV with semicolons, and the status line tells you which delimiter was found.

How are nested objects handled in JSON to CSV?

With Flatten nested objects turned on, a nested object becomes several columns with dotted names such as address.city. Arrays are written as JSON text inside one cell. Every key that appears in any object becomes a column.

Is my data uploaded?

No. The file is read and converted in your browser with Papa Parse. Nothing is sent to a server, so it is safe for customer lists and other private data.

More code and data tools

See all tools