CSV to JSON Converter

First row (JSON)—
Data rows—
Columns—

How CSV to JSON Converter is calculated: First row = headers; quoted fields may hold commas, newlines, and doubled quotes; numbers and booleans are typed, short rows get null.

What is a CSV to JSON converter?

CSV is the format spreadsheets speak: rows of values separated by commas, one record per line. JSON is the format programs speak: objects with named keys. When data arrives as a spreadsheet export and the destination is an API, a database, or a script, something has to translate — and that is what this converter does.

The translation is straightforward. The first row becomes the headers — the key names. Each row after that becomes one JSON object, with each value filed under its header. The default text on this page, three lines with name, age, and city, becomes two objects: one for Ada and one for Grace, each with three keys.

The tricky part is quoting, and this converter handles it properly. A field wrapped in double quotes may contain commas, newlines, and doubled quotes — all of which would break a naive split on commas. The parser reads the quotes, not just the commas, so a note like "lives in London, UK" stays one field instead of splitting in two.

Everything runs in your browser. Your data never leaves your device, nothing is uploaded or stored, and there is no account to create. You can convert sensitive records — customer lists, private exports, internal data — without worrying about who else sees them.

How CSV becomes JSON

The converter reads your CSV character by character with a small parser built for this page. A comma outside quotes ends a field. A newline outside quotes ends a row. A double quote at the start of a field opens a quoted field, which ends at the next lone double quote — and two double quotes in a row inside a quoted field mean one literal quote character.

That state machine is what makes quoted fields work. A comma inside quotes is part of the value, not a separator. A newline inside quotes is part of the value, not a new row. Without that distinction, a single address field could shatter a whole row into the wrong columns — and the parser never lets that happen.

The first row becomes the headers. Every row after that becomes an object whose keys are those headers, in the same order. Blank lines are skipped, so a trailing newline or an empty line in the middle does not create a phantom record with empty values.

Values are typed, not left as strings. A field that reads 36 becomes the number 36, true becomes the boolean true, and an empty value becomes null. A field that is too short — a row with fewer values than headers — gets null for the missing keys, which is honest: the data was not there.

Quoted fields, commas, and newlines

The classic CSV trap is a comma inside a value. A note like "lives in London, UK" contains a comma, and a parser that splits on every comma would cut it into two fields and shift every column after it. The correct fix is quoting: wrap the field in double quotes, and the comma inside stays part of the value.

The second trap is a newline inside a value. A multi-line note — "line one" on one line and "line two" on the next — looks like two rows to a naive reader. Inside quotes, the newline is part of the value, and the parser keeps the row together. The worked example below shows exactly that case.

The third trap is a quote inside a value. A field that contains a double quote writes it doubled: "say ""hello""" means the value say "hello". The parser reads two quotes in a row as one literal quote, which is the CSV rule, and it is the only way to put a quote inside a quoted field.

The fourth trap is an unclosed quote. A field that opens a quote and never closes it — a stray quote at the end of a file — makes the rest of the document one long field. The parser reports an unclosed quote instead of guessing, because guessing would silently merge rows that were never meant to merge.

A worked example: people, notes, and types

Start with the default text: name,age,city on the first line, then Ada,36,London and Grace,40,Berlin. The converter produces two rows and three columns, and the first row is {"name":"Ada","age":36,"city":"London"}. The age is the number 36, not the string "36" — the typing rule at work.

Now the quoting test: name,note on the first line, then Ada,"lives in London, UK" and Grace,"line one" followed by "line two" on the next line, all inside one quoted field. The result is still two rows and two columns, and the first row is {"name":"Ada","note":"lives in London, UK"}. The comma and the newline both stayed inside their values.

Try the types: id,active on the first line, then 7,true. The result is one row and two columns, and the first row is {"id":7,"active":true}. The id is a number and active is a boolean — both typed from their text, which is what code that reads the JSON expects.

Finally, try broken CSV: name,note on the first line, then Ada,"oops with the quote never closed. The converter reports an unclosed quote instead of producing JSON. There is no honest way to convert a document whose quotes do not match, so the tool refuses and says so plainly.

Who converts CSV to JSON, and why

Developers are the biggest users. Data arrives as spreadsheet exports and has to reach an API, a database, or a script — and all of those speak JSON. Converting once, at the boundary, is far easier than teaching every part of the system to read CSV.

Data analysts are the second group. They clean data in a spreadsheet and hand it to a developer, or they receive a CSV export and need to feed it into a tool that only accepts JSON. A converter does the translation in seconds, without a spreadsheet in between and without retyping anything.

Testers are a third group. They build test data as CSV because it is easy to write in bulk, then need JSON versions to feed into a test harness. Converting by hand is slow and error-prone; pasting the block here and copying the result takes seconds and cannot introduce a typo.

Students are a fourth group. Comparing the same data as CSV and JSON side by side is the fastest way to understand both formats. The converter shows the mapping in action: headers to keys, rows to objects, quoted fields to values — and the differences between the two formats become obvious.

CSV to JSON vs JSON to CSV

The two directions are mirror images, and they are both needed. Use this converter when the data arrives as CSV — a spreadsheet export, a downloaded report, a mailed file — and the destination needs JSON. Use the reverse converter when the data starts as JSON and the destination is a spreadsheet.

The rules are the same in both directions, which is why the pair works as a round trip. Quoted fields survive the trip in both directions, numbers stay numbers, and the header row maps to keys and back. Convert CSV to JSON and back again, and you get the same table — with the same values in the same columns.

Reading the input first is good practice. A sort lines pass can order the rows before converting, and a text formatter cleans up plain text that came out of a document. Sort and clean first, then convert — the converter is the second step, not the first.

Checking the result is another job. A JSON formatter prints the converted JSON neatly so you can read it, and a word counter tells you how big the block is. Convert first, then read the result — in that order.

Common CSV mistakes

The most common mistake is a comma in an unquoted field. A value like London, UK written without quotes splits into two fields and shifts every column after it. The fix is quoting: wrap any value that contains a comma in double quotes. Spreadsheets do this automatically when they export — the mistake happens when people type CSV by hand.

Second: header names that repeat. Two columns both called name produce objects with one name key, and the second value overwrites the first. Rename the headers before converting — name and full_name, for example — so every column has its own key.

Third: assuming every row has the same length. A short row gets null for its missing keys, which is honest, but it usually means a comma was missed or an extra quote swallowed a separator. If a row converts with nulls you did not expect, look at that row's quoting first.

Fourth: Excel quirks. Excel sometimes saves CSV with a byte-order mark at the start, or with semicolons instead of commas when the system language uses commas as decimal separators. If the converter reports a problem and the CSV looks fine, check for a hidden mark at the start or a semicolon where a comma should be.

How to use this CSV to JSON converter

Using this converter is simple. Paste your CSV into the box, or type it directly. The JSON appears instantly in the box below, printed with two-space indentation, with the first row, the row count, and the column count shown above it. There is no button to press and no form to submit.

To use the result, select the text in the output box and copy it. To convert another block, select all, delete, and paste the new one — the counts reset instantly. If the CSV is invalid, the output box shows the error message instead; read it, fix the quoting it points to, and paste again.

Everything runs in your browser. No sign-up, no account, no data sent anywhere — your CSV never leaves your device. It works offline once the page has loaded, so you can use it on a plane, in a server room with no signal, or anywhere else you move data between formats.

Try it with something real before you need it: export a small sheet as CSV and convert it here. Once you have used it twice, the mapping — headers to keys, rows to objects — becomes second nature, and the spreadsheet-to-API gap stops being a chore.

Frequently Asked Questions

Nothing — as long as the value is wrapped in double quotes. A field like "lives in London, UK" stays one field, because the parser reads the quotes: a comma inside quotes is part of the value, not a separator. An unquoted comma always splits the field, which is why values containing commas must be quoted.

The same rule applies. A newline inside a quoted field is part of the value, so a multi-line note stays in one row instead of splitting into two. A newline outside quotes ends the row. That distinction is what lets CSV hold addresses and notes that span several lines.

Yes. A field that reads 36 becomes the number 36, true becomes the boolean true, and an empty value becomes null. Everything else stays a string. That typing is what makes the JSON useful in code. Watch out for values that must stay strings, like postcodes with leading zeroes — 01234 becomes the number 1234.

The missing keys get null, which is honest: the data was not there. It usually means a comma was missed or an extra quote swallowed a separator, so check that row's quoting first. Extra values beyond the header count are ignored.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.