CSV to JSON converter

Convert CSV to JSON or JSON to CSV, with delimiter detection, header handling and lossless type conversion.

CSV
JSON

Output will appear here

What this tool does

CSV is what spreadsheets, database exports and analytics dashboards hand you; JSON is what APIs and code want. This tool converts between them in both directions, in your browser. Paste CSV and you get a JSON array — objects keyed by the header row, or plain arrays when the data has no header. Switch direction and a JSON array becomes CSV, with every value quoted exactly as much as it needs to be.

The work happens on your device, which matters because CSV is the format people export customer lists, invoices and analytics extracts into. None of that is uploaded anywhere.

Why splitting on commas is not enough

The obvious way to read CSV — split each line on commas — breaks on real files, because the format has an escape mechanism. A field wrapped in double quotes may contain the delimiter, a literal quote written as two quotes in a row, or even line breaks, in which case one record spans several lines of the file. This tool implements the actual rules (RFC 4180) with a character-by-character parser, so all three cases come through intact.

name,note
Grace,"rear admiral, USN"
Ada,"she said ""hello"""
Alan,"two
lines"

Those four records have two fields each, despite the extra commas, quotes and newline. If quoting is malformed — a field opens a quote and never closes it — you get the line and column where the run-away quote started rather than a silently mangled table.

The delimiter is often not a comma

Despite the name, comma-separated values frequently are not. In locales where the comma is the decimal separator — most of continental Europe — Excel exports with semicolons instead, because 1,50 is a number there. Database and command-line tools often emit tab-separated data, and log pipelines like pipes. Pasting one of those into a comma-only tool produces a single very wide column, the most common CSV frustration there is.

So the delimiter is detected rather than assumed. Each candidate is tried, and the winner is the one that yields the same number of columns on every row — consistency, not the highest count, because a file full of decimal commas would otherwise look comma-separated. The detected delimiter is always displayed, and you can override it if the guess is wrong.

Headers and the shape of the output

With "first row is a header" on, that row supplies the key names and the output is an array of objects — the shape almost every API expects. With it off, every row becomes an array of values, which is what you want for a file that starts straight into data.

  • A row with fewer fields than the header gets empty strings for the missing columns, rather than keys with undefined values.
  • Duplicate header names are made unique (id, id_2, id_3) instead of overwriting each other, which would silently drop columns.
  • An empty header cell becomes column_2, column_3 and so on, so no key is the empty string.
  • Blank lines are skipped, the way spreadsheet importers do — a pasted file often ends with a stray newline, and a row of empty values there looks like a bug.

Type conversion that cannot lose data

Every CSV field is text. Converting text that looks numeric into JSON numbers is usually what you want — but it is also how data quietly gets destroyed. A zip code of 01234 becomes 1234. A 20-digit order number becomes a rounded float. A price written 1.50 loses its trailing zero.

The rule used here avoids all of that without a list of special cases: a value becomes a number only if converting it back to text reproduces the original exactly. 42 does, so it converts. 01234 does not, so it stays a string. Neither does 1.50, +5, 1e5, or any integer past the point where doubles lose precision. The strings true and false become booleans; an empty field stays an empty string rather than becoming null, because CSV cannot express the difference between "no value" and "empty value", and inventing one would be inventing information.

Going back to CSV

In the other direction, an array of objects becomes a table whose columns are the union of all keys, in the order they first appear — so rows with different keys still line up, and a missing key produces an empty cell. An array of arrays is written row for row. Quoting is applied only where the format requires it: a value containing the delimiter, a quote, or a line break gets wrapped, with inner quotes doubled.

Values that CSV has no way to represent — a nested object or array — are written as JSON inside their cell rather than flattened or dropped, so nothing disappears in a conversion. Null becomes an empty cell.

Frequently asked questions

Why did my file come out as one giant column?
The delimiter is not what the tool used. That usually means a semicolon file (standard for Excel in European locales, where the comma is the decimal separator) or a tab-separated export. Detection normally catches this — check which delimiter is shown, and pick another from the dropdown if it guessed wrong.
Why is my ID still a string in the JSON?
Because converting it would change it. Numbers convert only when the conversion is exactly reversible, so 01234 keeps its leading zero and long IDs keep every digit. If you genuinely want them as numbers, your data has to be written without the leading zero, or you can convert after the fact where you control the precision.
What happens to commas and quotes inside a field?
They are preserved. On the way in, a quoted field may contain commas, doubled quotes and even newlines; on the way out, any value containing the delimiter, a quote or a line break is quoted and its inner quotes doubled. A value round-trips through CSV → JSON → CSV unchanged.
Is my data uploaded anywhere?
No. Parsing and conversion run entirely in your browser, so the customer lists, exports and reports that usually live in CSV never leave your device.