CSV to JSON Converter

Convert CSV data to JSON in the browser, handling quoted fields, embedded commas and line breaks — the cases that defeat a naive split on commas.

CSV is not a format you can split on commas

It looks like the simplest format there is, which is exactly why so much code gets it wrong. RFC 4180 lets any field be wrapped in double quotes, and a quoted field may contain commas, line breaks, and quotes — the last written as two quotes in a row. Splitting on commas handles none of that.

RowSplit on commasActually
a,b,c 3 fields 3 fields
Smith,"Jones, Robert",42 4 fields 3 fields
title,"He said ""no""",5 3 fields 3 fields
a,,c 3 fields 3 fields
widget,"1,299.00",in stock 4 fields 3 fields
ACME,"1 High St, Springfield, IL",yes 5 fields 3 fields

Wrong on 3 of 6 entirely ordinary rows — a customer name, a price with a thousands separator, a street address. And always wrong in the same direction, producing too many fields, which is why it usually surfaces as a column-count mismatch far away from the actual cause.

The greyed rows are the ones it gets right. Notice that a plain row with no quoting is among them: naive splitting works perfectly on the test data most people write, and fails on the real data that arrives later. That is the shape of a bug that ships.

And a row is not a line

One case does not just break the splitting — it breaks the shape of the program. A quoted field is allowed to contain a newline. So this:

id,note
1,"line one
line two"
2,ok

is 4 lines of text and 3 rows of CSV. The middle row's second field contains a line break, and it is supposed to. No amount of care about the splitting fixes this, because the row boundary and the line boundary are different things. Any program built around "read a line, then parse it" cannot represent the data at all.

The correct approach is to walk the text character by character, tracking whether you are currently inside a quoted field. That is about thirty lines of code and it is what this converter does. Feeding it the same awkward data — names with commas, embedded quotes, a multi-line cell, empty and space-padded fields — and writing it back out gives:

name,note,qty
"Smith, John","said ""hi""",3
"multi
line",plain,0
,empty name,1
trailing space , leading,2

That round-trips back to the original 5 rows exactly — checked on every build, along with 3,000 generated rows built from commas, quotes and newlines. A line-splitting reader given the same text finds 6 rows instead of 5, and reports no error while doing it.

Writing CSV has the same rules in reverse

Going the other way, a field needs quoting if — and only if — it contains a comma, a double quote, or a line break. Quotes inside get doubled. Everything else is written bare, which keeps the file readable:

ValueWritten as
plain plain
a,b "a,b"
say "hi" "say ""hi"""
two\nlines "two\nlines"
(empty) (nothing)

One thing worth flagging because no rule can fix it: a trailing empty field is genuinely ambiguous in CSV. The line a,b, could be three fields with the last one empty, or two fields with a stray comma, and the format does not say which. Most parsers choose three. If your data can end in an empty value, that is a place to check what the other end assumes rather than trust it.

How to use

  1. Paste or upload your CSV.
  2. Confirm the delimiter and whether the first row is a header.
  3. Review the parsed output before copying it.
  4. Check a row containing quotes or commas to confirm parsing is correct.

Frequently asked questions

Why can't I just split on commas?

Because a field may contain a comma inside quotes, and quoted fields may contain line breaks. Splitting on commas breaks such a row into the wrong number of columns, and the failure is silent — you get data, just misaligned. Proper CSV parsing has to track whether it is inside a quoted field.

How are quotes inside a field escaped?

By doubling them. A field containing a quotation mark is written with two, so ""quoted"" inside a quoted field yields one pair of quotes in the value. This is the RFC 4180 convention and the one most tools follow.

Does my data get uploaded?

No. The conversion runs entirely in your browser, so the file never leaves your device. That is the main reason to use a local converter for anything containing customer records, financial data or anything else you would not paste into an unknown website.

What happens to numbers and dates?

CSV has no types — everything is text. A converter has to guess whether 007 is a number or a string, and whether 03/04/2026 is March or April. Leading zeros and ambiguous dates are the usual casualties, so check identifiers and dates in the output specifically.

What if my file uses semicolons?

That is common in locales where the comma is the decimal separator, particularly across Europe. Set the delimiter accordingly. Tab-separated files are also widespread and are usually easier to parse because tabs rarely appear inside fields.

Should the output be an array of objects or arrays?

Objects keyed by column name are easier to read and more robust to column reordering. Arrays are more compact and preserve column order exactly. Objects are the better default unless file size genuinely matters.

🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.