Open tools · 0

About

CSV to JSON

Drop a CSV, TSV or Excel file, or paste the rows, and save it as JSON: an array of objects keyed by the header, an array of arrays, or JSON Lines. The separator and the encoding are found for you, and each column gets one type, so a column of numbers becomes numbers and a column of codes stays text.

What it does

  • A column whose every filled cell is a number is written as numbers, each as typed: 1.50 stays 1.50.
  • One cell such as 007 keeps its whole column as text, so codes with leading zeros never lose them.
  • A number longer than 15 digits, such as an order number, makes its column text, since JSON.parse would round it.
  • A column of TRUE and FALSE, as Excel writes them, or True and False from Python, becomes true and false.
  • Empty cells become null; with Typed values off, every cell is a string and an empty one is "".
  • Two columns of one name are kept apart as name and name (2), and a file with no header gets Column 1, Column 2.
  • A quoted cell holding line breaks stays one value, with its breaks kept inside the string.

How to use it

  1. Drop the file on the window, or paste the rows into the box under it.
  2. Keep First row is the header ticked if that row names the columns.
  3. Turn amounts such as 1.234,50 into plain numbers with Tidy numbers… on their column, or they stay text.
  4. Save as JSON, pick Objects, Arrays or JSON Lines, then copy it or download it.

What it does not do

  • Nested objects: a column named address.city stays one key with a dot in it, as the file had it.
  • Dates as a type: JSON has none, so they stay strings; Tidy dates… writes a column of them as 2024-05-12 first.
  • Guessing what 1.234,50 means: the comma could mark decimals or thousands, so the cell stays text until its column is tidied.

Questions

Why are the numbers in one of my columns strings?

Because one cell in that column is not a plain number: a leading zero, a decimal comma, a currency sign or more than 15 digits. The whole column is then written as text, so a program reading the JSON finds one type in each field.

Which of the three shapes should I pick?

Objects, one {"Name": "Ada"} per row, is what most APIs and scripts expect. Arrays puts the column names in a first list and each row in a list after it, which is shorter for wide tables. JSON Lines writes one object a line, saved as .jsonl, for loaders that read a line at a time.

Can I convert an Excel file to JSON?

Yes: drop the .xlsx and its first sheet opens, with the others a pick away. Numbers come out as they were stored rather than as the cells displayed them, and dates as text such as 2024-05-12.

Why does the JSON say null where my file had nothing?

An empty cell has no value, and null is how JSON says so, which a program can tell apart from an empty string. Untick Typed values for "" instead; every other cell then becomes a string as well.

Everything here runs in your browser. Nothing you type, paste or open is uploaded, and there is no account and no queue. How that works.

Often used with

More in Converters

  • Unit Converter: Convert length, weight, temperature, volume, area, speed, data size and nine more quantities, both ways, with the formula.
  • Base64 Encode & Decode: Encode text or files to Base64 and decode it back: URL-safe, MIME line breaks, data URIs, and images you can preview.

All toolsAbout utilbrewPrivacy