Converters
CSV to JSON
Turn a pasted CSV export into a JSON array of objects, keeping a quoted line break inside its cell so the records match the file you started with.
Ready to run. Input limit: 1 MB characters.
JSON output
—
Output actions
Ready to copy output once your result appears.
Headers become keys, quotes stay inside the cell
CSV to JSON reads CSV input and writes a JSON array of objects. Input delimiter starts on Auto-detect. Infer numbers, booleans and null starts unchecked, so every cell remains a string. Convert to JSON runs the parse. A delimiter preview appears once the box is non-empty and shows the separator in JSON quotes, such as ";". Load sample fills a semicolon file with a quoted semicolon and a quoted line break, and does not convert. Reset clears the box and the result. Copy output and Download output use the JSON. The download file is csv-to-json.json.
How to turn CSV into records
- 1Paste CSV that has a header row and at least one data row, or press Load sample. The sample uses semicolons. Its second note cell contains a real line break inside quotes.
- 2Leave Input delimiter on Auto-detect and read the preview, or pick Comma, Semicolon, Tab, or Pipe. Leave Infer numbers, booleans and null off when postal codes and ids must stay text.
- 3Press Convert to JSON. A success says Converted successfully. and JSON output is pretty-printed with two-space indent. Changing the delimiter or the checkbox does not rerun. Editing the CSV clears the previous JSON.
What it is good for
- • Turning the semicolon sample into two objects whose note fields still contain the semicolon and the line break.
- • Keeping 001 as the string 001 until you decide an id may become a number.
- • Rejecting a file whose second header repeats the first, instead of dropping a column.
Example
Input
name;age;note Alice;30;"Hello; world" Bob;25;"Two lines"
Output
[
{
"name": "Alice",
"age": "30",
"note": "Hello; world"
},
{
"name": "Bob",
"age": "25",
"note": "Two\nlines"
}
]Auto-detect chooses semicolon, and the preview shows ";". Infer is off, so age is the string "30" and the line break inside Bob's note is a JSON \n escape, not a broken row. Press Load sample, then Convert to JSON.
What the parser keeps inside a cell
The first row is the header. Each header becomes a property name, and each later row becomes one object. Headers must be non-empty after you look at them, and they must be unique. A repeated header stops with Headers must be non-empty and unique. A file that is only a header, with no data row, stops with Need at least a header row and one data row. A data row whose field count differs from the header stops with a message that names the file row, counting the header as row 1. Row 2 has 1 fields; expected 2. is the usual shape. The page does not pad a short row and does not discard an extra field.
Quotes follow a small CSV rule. A quote opens a cell only at the start of that cell. Inside the quotes, a delimiter and a line break are data. Two quotes in a row are one quote character. A quote that never closes stops with Unclosed quoted CSV field. A quote that appears after the cell already closed, or a stray quote in an unquoted cell, stops with Malformed CSV quoting. Quote entire cells and escape quotes as two quotes. A leading byte-order mark is removed before the parse, so a file saved with a BOM can still use its first header. Whitespace inside a cell is kept. The page does not trim " Ada" down to Ada.
Input delimiter, the preview, and type inference
Auto-detect tries comma, semicolon, tab, and pipe against the first 20 parsed rows. A candidate scores its width when that width is greater than 1 and every tested row has the same width. The highest score wins. A tie keeps the earlier candidate, and comma is first, so a file that is only one column, such as only then line, resolves to comma. The preview prints JSON.stringify of the chosen character. The sample's preview is ";" including the quote marks. An explicit choice skips detection and the preview shows that character the same way, so a tab appears as "\t". If the text cannot be parsed for the preview, the line says invalid input. The preview does not convert. You still press Convert to JSON.
Infer numbers, booleans and null starts off. Off means every cell is a JSON string, including 30, true, and null. On, the cell must match exactly. null becomes JSON null. true and false become booleans. A numeric pattern without a leading zero, optional fraction, and optional exponent, within the safe integer range, becomes a number. 2.5 becomes 2.5. 1e2 becomes 100. 001 stays the string 001 because of the leading zero. A space before a digit, as in the two characters space and 1, stays a string. 9007199254740993 stays a string because it is past the safe integer limit. NULL in capitals stays a string, because only the exact letters null are special. The CSV delimiter converter changes the separator and does not build objects. This page builds the objects and can leave the separator decision to Auto-detect.
When JSON records are the form you want
Use this page when a spreadsheet export should become an array you can paste into a test, a fixture, or another converter. The sample is the case that usually goes wrong in a naive split: the semicolon inside Hello; world must not start a new field, and Bob's note must keep its line break. Both survive. The download is csv-to-json.json. The input cap is 1,000,000 characters, with the same too-large message the other data tools use. An empty box says Enter an input first.
Going back to a sheet is JSON to CSV, which expects an array of objects and can flatten nested objects this page will never create, because a CSV cell does not become a nested object here. An INSERT for PostgreSQL, MySQL, or SQLite is CSV to SQL, which shares the delimiter control and the inference checkbox but writes SQL instead of JSON. The guide Convert nested JSON to CSV without losing fields is the other direction's walkthrough. This page is the check you do before that, when the file you hold is still CSV and you want to see the records.
Leading zeros, duplicate headers, and a quote left open
Leave inference off for anything that only looks numeric. A postal code, a product id, and a phone number are the usual casualties. 001 with inference on is still the string 001, which is the safe case, but 10 stays a number and a later zero-padded cousin in another file might not match it. If you turn inference on, read the JSON before you download it. true must be the four letters in lowercase. True stays a string. The word null with inference on becomes a JSON null, which is not the same as an empty cell. An empty cell stays the empty string even when inference is on, unless you are on the SQL tool and have asked for NULL.
A header is a key, taken literally. Two columns both named id are an error, not a silent overwrite. A blank header is an error. A header whose text is __proto__ becomes an own property of the record rather than a change to the object's prototype. The row-width check uses the header's length, so a trailing delimiter makes an extra empty field and will fail if the header did not have that extra column. An unclosed quote often comes from a note that contains a line break and lost its closing quote in the export. The error is Unclosed quoted CSV field. Fix the quote in the box and convert again. The previous JSON is cleared when the CSV text changes, so a failed click does not leave the last good array pretending to match the broken file.
Rules and limitations
The first row is a unique, non-empty header. Every data row has the same field count. Quoted cells may contain the delimiter and line breaks. A doubled quote is one quote. A BOM is ignored. Cells are not trimmed.
Auto-detect picks comma, semicolon, tab, or pipe from the first 20 rows, preferring a consistent width above 1, with comma winning a tie. Inference is off unless checked, and it only converts exact null, true, false, and safe numbers without leading zeros. The download file is csv-to-json.json.
Common problems
If a semicolon file became one column, the preview probably shows ",". Pick Semicolon and press Convert to JSON again. Auto-detect can prefer comma when both separators look rectangular.
If an id lost its leading zeros, inference is on and the value matched the number pattern. Uncheck it. If the error names a row width, a quote broke or a delimiter was left inside an unquoted cell.
Frequently asked questions
Does the sample's age become a number?
Not until you check Infer numbers, booleans and null and convert again. With the box unchecked, "30" stays a string.
Can a cell contain a line break?
Yes, inside double quotes. Bob's note in the sample is one field, and the JSON shows it as an escaped newline.
Why are two headers named id rejected?
A JSON object would keep only one of them. The page stops so both columns remain visible in the error instead of one value disappearing.
What does the delimiter preview's quote marks mean?
The preview prints the separator with JSON.stringify. Semicolon looks like ";" and a tab looks like "\t". That line is not the JSON output.
Is my input uploaded or saved?
This tool processes input in your browser and does not save its input or output to local storage. Copy and download are user actions. The site uses analytics for page and action metadata and may use ads and production error reporting; see the Privacy Policy for those services.
About this tool
Maintained by Toolbench. For large or deeply nested files, split the input into smaller batches and verify representative results before using them in an import or application. Report reproducible problems through Contact.
Guides
- Convert nested JSON to CSV without losing fields
Choose between flattened columns and JSON cells, preserve arrays and review missing values before exporting.
- Prepare CSV for PostgreSQL, MySQL or SQLite INSERT
Validate records, preserve identifiers, choose NULL behavior and inspect generated SQL before importing.
Next steps
Related tools
Continue the workflow with nearby tools for formatting, publishing, debugging, or follow-up checks.
JSON to CSV
Convert a JSON array of objects to CSV.
Open JSON to CSVCSV Delimiter Converter
Rewrite CSV between comma, semicolon, tab, and pipe without splitting quoted cells.
Open CSV Delimiter ConverterCSV to SQL
Generate SQL INSERT statements from CSV. Choose a SQL dialect, quote identifiers and strings, and control NULL and type inference.
Open CSV to SQLJSON to TypeScript
Generate nested TypeScript interfaces from example JSON, including array unions and optional fields.
Open JSON to TypeScriptTrust
Policies, contact, and answers
Clear pages for how Toolbench works, what we collect, and how to reach us.