Back to blog
Developer Tools Data CSV

CSV to JSON & JSON to CSV: A Practical Conversion Guide

Published: Updated: Reading time: about 6 min
Share:

Spreadsheets export as CSV; APIs return JSON; and someone always needs the other format. Converting between them sounds trivial until a cell contains a comma, a quote, or a newline. This guide explains how CSV and JSON map to each other, the rules that break naive converters, and how to convert safely online.

How CSV and JSON Map

CSVJSON
Header rowObject keys
Data rowObject
All rowsArray of objects
Cell valueString, number, boolean or null

Without a header row, a CSV converts to an array of arrays instead. Most converters offer both modes.

The Quoted-Cell Rule (Where Most Converters Fail)

CSV allows commas, quotes and newlines inside cells if they're wrapped in double quotes, with internal quotes doubled:

name,note
Ada,"said ""hi"", then left"
Lin,"first line
second line"

A converter that just splits on commas will destroy this data. A correct parser tracks quote state across the whole row — which is what the converter here does.

Type Detection: Numbers, Booleans, Strings

CSV cells are always text. When converting to JSON, a good converter infers types: 42 → number, true → boolean, everything else → string. Beware of implicit conversions — ZIP codes and phone numbers should stay strings, so use quotes in the source or check the output.

How to Convert CSV & JSON Online

  1. Open the tool: go to the CSV converter.
  2. Paste or upload: CSV, TSV or JSON input — the tool detects the direction.
  3. Pick the delimiter: comma, tab, semicolon or custom, depending on your file.
  4. Toggle the header row: with a header, rows become keyed objects; without, they stay as arrays.
  5. Preview the table: check the parsed structure, then copy or download the output.

Tip: if your CSV came from Excel on a European system, it may use semicolons — set the delimiter explicitly instead of assuming commas.

Frequently Asked Questions

Why did my CSV break when opened in Excel?

Likely the wrong delimiter (semicolon vs. comma) or unescaped quotes. Convert TSV→CSV with the right delimiter, or re-export from your spreadsheet with comma separators.

Should ZIP codes or phone numbers become numbers?

No — keep them as strings. Type inference converts "00123" to 123 unless the field is quoted. Check the output for leading-zero loss.

Can JSON with nested objects go to CSV?

Only flat objects convert cleanly. Nested objects are usually stringified or flattened; array-of-arrays CSV is the safe path for tabular data.

Is my data uploaded when I convert?

No. The CSV converter parses everything locally in your browser — even sensitive spreadsheets stay on your device.

References

  1. RFC 4180 — CSV format specification: https://datatracker.ietf.org/doc/html/rfc4180
  2. JSON specification — RFC 8259: https://datatracker.ietf.org/doc/html/rfc8259

Related Reading