Skip to content

Converting Between CSV and JSON Without Losing Data

How delimiters, quotes, types and formulas can bite when you convert spreadsheet data to JSON and back.

By Malik Shaheer, Founder and web developer · Updated 4 November 2026 · Steps checked against the live tools

CSV is the universal spreadsheet export; JSON is the universal language of web APIs. Converting between them looks trivial until quoted commas, leading zeros or nested data appear. Knowing the traps keeps your data intact.

What CSV really is

A CSV file is rows of text with fields separated by a delimiter, usually a comma. Fields that contain the delimiter, a quote or a line break are wrapped in double quotes, and a quote inside a quoted field is doubled. Some regions use semicolons because the comma is their decimal separator, and tab- or pipe-separated files are common too.

Because of this, splitting a line on commas is not enough. A proper parser follows the quoting rules, including line breaks inside quoted fields.

Headers and duplicates

JSON objects need unique keys. If two columns share a name, a converter must rename one, for example by adding a suffix. If a file has no header row, you will want generated names or arrays instead of objects.

Types: strings versus numbers

CSV has no types; everything is text. Turning “42” into the number 42 is convenient, but turning “007” into 7 or a 17-digit ID into a rounded number corrupts data. The safe default is to keep identifiers and very long numbers as text and convert only plain values such as 42, 3.14, true and false.

Going from JSON to CSV

CSV is flat, so each JSON object becomes a row and each key a column. If objects have different keys, the columns are the union of all keys and gaps stay empty. Nested objects and arrays do not flatten neatly; they are usually written as JSON text inside one cell, so consider flattening your data first.

Spreadsheet formula injection

If a cell begins with =, +, - or @, spreadsheet programs may treat it as a formula. When you open a CSV containing untrusted text, that can be a security risk. Prefixing such cells with an apostrophe neutralises them but changes the data, so decide deliberately whether you want that protection.

A safe workflow

  • Validate or inspect the source first.
  • Convert with type detection off, then turn it on only if you need real numbers.
  • Spot-check the first and last rows plus any row with quotes or line breaks.
  • Keep the original file; conversion is not always reversible.

Found a mistake or something out of date? Email support@toolzaura.pro and we will fix it.

Try these tools

CSV to JSON

Convert CSV rows to a JSON array.

Developer Tools

JSON to CSV

Flatten a JSON array into CSV.

Developer Tools

JSON Formatter

Beautify JSON with consistent indentation.

Developer Tools

JSON Validator

Check JSON syntax and point to the error.

Developer Tools