DataSwap Fast file & data format converters, no signup

CSV to JSON Converter

Paste CSV below — the first row is used as headers. Quoted fields with embedded commas, newlines, and escaped quotes are parsed correctly, not split naively. Nothing you paste ever leaves your browser.

Why a real CSV parser matters

CSV looks simple — split on commas, split on newlines, done — until a field itself contains a comma. The CSV spec's answer is to wrap such a field in double quotes, and to escape any literal quote inside it by doubling it (""). A field can even contain a real newline as long as it's inside quotes. A naive split(",") parser doesn't know any of this: it treats every comma as a column boundary, so a single quoted field like "Smith, John" gets sliced into two columns and every field after it in that row shifts out of alignment — silent corruption, not an error. This tool instead reads the input one character at a time, tracking whether it's currently inside a quoted field, so quoted commas and newlines stay part of the field they belong to.

Worked example

Input:

name,city
"Smith, John","New York"
"O""Brien",Boston

Row one has a comma inside a quoted name — a naive parser would read that as four columns instead of two and wreck the rest of the table. Row two has an escaped "" quote, which must collapse to a single literal ". This tool produces:

[
  {
    "name": "Smith, John",
    "city": "New York"
  },
  {
    "name": "O\"Brien",
    "city": "Boston"
  }
]

— two clean rows, the embedded comma preserved as part of the name, and O""Brien correctly collapsed to a single O"Brien.

Frequently asked questions

Why not just split each line on commas?

Because real CSV allows a comma inside a field, as long as the field is wrapped in double quotes — a name like "Smith, John" is one field, not two. A naive split(",") would break that field in half and shift every column after it out of alignment for the rest of the row. This tool uses a proper character-by-character parser that tracks whether it's currently inside a quoted field, so a comma there is just text, not a delimiter.

My CSV uses semicolons, not commas — will this still work?

Yes — use the delimiter selector above the input to switch between comma, semicolon, and tab. Semicolon-delimited CSV is the default export format for Excel in several European locales, precisely because those locales use a comma as the decimal separator (so "3,14" means pi, not two values) — a comma-delimited file would be genuinely ambiguous there.

What happens if a row has more or fewer fields than the header row?

It won't crash or silently misalign your data. If a row is short, the missing trailing fields are filled in as empty strings. If a row has extra fields beyond the last header, those extras are dropped. When this happens anywhere in your file, a note appears above the output telling you how many rows were affected, so you can go check the source.

Is my CSV data uploaded anywhere?

No. Parsing happens entirely in your browser with plain JavaScript — nothing you paste is sent to a server, stored, or logged. That's true for every tool on this site.