Data guide

CSV and JSON conversion without surprises

Reviewed October 13, 2026 ยท About 8 minutes

CSV represents a table. JSON represents values, lists, and objects. Conversion is straightforward when JSON contains a list of flat records and CSV has a clean header row. It becomes ambiguous when data is nested or when a CSV file uses inconsistent formatting.

CSV is a convention, not one rigid layout

Most CSV files separate fields with commas, but regional exports may use semicolons. Fields containing commas, quotes, or line breaks need quoting. A reliable parser understands escaped quotes rather than simply splitting every line at each comma. TSV uses tabs and can be easier when text contains many commas.

The first row usually becomes field names

When converting CSV to JSON, headers such as name, email, and created_at become object keys. Duplicate or empty headers cause confusion. Rename them before conversion and keep names stable if another program depends on the result.

Text can look like another data type

CSV does not reliably distinguish text from numbers, dates, or booleans. A postal code such as 00501 may lose leading zeroes if software treats it as a number. Long identifiers can be rounded by spreadsheets. Dates such as 03/04/26 are ambiguous across regions. Preserve these values as text unless you control the consuming system.

Nested JSON does not fit a simple table

An object can contain another object or a list. A CSV cell cannot naturally hold that structure. A converter must flatten keys, serialize the nested value as text, create extra rows, or reject the input. Each choice changes meaning. For important data, define a flattening rule before conversion.

Good fit: an array such as [{"name":"Ava","city":"Austin"}] maps cleanly to a two-column CSV. An order containing customer details and a list of products needs a deliberate schema.

Empty, missing, and null are different

An empty CSV cell might mean an empty string, an unknown value, or a missing field. JSON can represent "", null, or omit the key. Decide which meaning your destination expects. A round trip from JSON to CSV and back may not preserve that distinction.

Character encoding

UTF-8 is the safest modern choice for names, symbols, and multiple languages. If accented letters turn into replacement characters, the source may use a legacy encoding. Open it in the program that created it and export as UTF-8 before conversion.

Validation checklist

  1. Count the source records and converted rows.
  2. Check the header names and column order.
  3. Inspect commas, quotes, tabs, and multiline text.
  4. Verify leading zeroes, long numbers, dates, and non-English characters.
  5. Confirm how empty and nested values were handled.
  6. Import a small result into the destination system before converting the full dataset.

Use the CSV to JSON, JSON to CSV, CSV to TSV, or TSV to CSV tools for flat everyday data.