Toolstia / Guides

CSV vs JSON: which should you use, and how do you convert between them?

5 min read

Both formats store data as plain text, but they suit different jobs. Knowing the difference saves hours of cleanup.

What each one is good at

  • CSV is a flat table: rows and columns, like a spreadsheet. It is compact, opens in Excel and Google Sheets, and is easy for non-programmers.
  • JSON holds structured data with nesting, lists and data types. It is the standard format for web APIs and settings files.

Use CSV when

  • Your data is a simple table.
  • People will open or edit it in a spreadsheet.
  • You are importing or exporting contacts, products or orders.

Use JSON when

  • Records contain lists or objects inside them, such as an order with several items.
  • You need to tell numbers, text and true/false apart.
  • The data goes to or from an API.

How the conversion works

To turn CSV into JSON, the first row becomes the keys and each following row becomes an object. To go the other way, the tool needs an array of objects, and the columns are all the keys it finds.

The CSV to JSON converter handles both directions, detects semicolons and tabs, and can convert numbers and true/false into real values.

name,age
Ann,30
Bo,25

[
  { "name": "Ann", "age": 30 },
  { "name": "Bo", "age": 25 }
]

Quoting rules

If a value contains a comma, a quote or a line break, it must be wrapped in double quotes, and any quote inside it is doubled. So the text He said "hi" becomes "He said ""hi""". Most hand-made CSV problems come from forgetting this.

Leading zeros are not numbers

Phone numbers, postcodes and codes such as 007 must stay as text, or the zeros disappear. The converter keeps values with leading zeros as text for this reason.

The Excel and Bangla text trap

If you double-click a UTF-8 CSV file that contains Bangla, accented letters or emoji, Excel can show it garbled. The reliable fix is a byte order mark at the start of the file, which the converter adds to the CSV it downloads. You can also open Excel, choose Data, then From Text/CSV, and set the encoding to UTF-8.

Nested data in a flat table

A table has no room for objects inside a cell. The converter writes nested values as JSON text in the cell. If you need real columns, flatten the data first.