CSV ↔ JSON Converter
Turn CSV into JSON, or flat JSON objects into CSV. Problems are reported with their place instead of being guessed at, and your data stays on your device.
Add your CSV, then press Convert. A summary appears here.
How to convert between CSV and JSON
Pick a direction
Choose CSV to JSON or JSON to CSV. Each tab keeps its own input, settings and result.
Add your data
Type or paste it, import a local UTF-8 file, or load the example. Check the delimiter and options.
Convert and use the result
Press Convert, read the summary, then copy the output, download it, or use it as the input of the other tab.
CSV to JSON
- Every value stays a string. The result is an array of objects, and every value is a JSON string exactly as written: zip codes such as 01234, numbers such as 1.50, spaces at either end, and empty cells (which become
""). Numbers, dates, true/false and null are never guessed. Convert them in the program that reads the JSON. - Delimiters. Comma, semicolon and tab. Auto-detect counts each delimiter in the first row, outside quotes, and picks the most frequent one. The detected delimiter is shown before and after converting, and you can choose another. If only one column results but the first row holds another delimiter, the summary points that out.
- Column names. By default the first row holds the names and becomes the keys. Empty names and repeated names are errors, because an object cannot hold the same key twice; nothing is renamed or overwritten. Without a header row the keys column1, column2 and so on are generated. A name such as
__proto__is an ordinary key. - What the CSV reader accepts. Values may be wrapped in double quotes and then contain delimiters, doubled quotes and line breaks. A UTF-8 byte order mark is ignored, and CRLF, LF and CR line breaks all work. Quotes in the wrong place, an unclosed quote, and rows with a different number of values than the first row are errors with the record number and line.
- Empty lines. One line break at the very end is ignored. An empty line anywhere else is a record: in a CSV with several columns it is an error (remove the line), and in a one-column CSV it is an empty value. Empty lines are never dropped quietly.
- Header only. A CSV with only a header row converts to an empty array, and the summary says 0 rows.
JSON to CSV
- Flat objects only. The JSON must be an array of flat objects, one object per row: strings, numbers, true/false and null. Columns are all keys in the order they first appear, and rows keep their order. A nested object or array is refused with its location and a reason; it is not flattened or turned into text for you. So are repeated keys in one object, items that are not objects, and a single object outside an array.
- An empty array. An empty array has no keys, so no columns can be inferred. You get an explanation and no file, not an empty or header-less CSV.
- CSV cannot keep every distinction. A missing key, null and an empty string all become an empty cell, and the summary counts the missing and null ones. The number 1 and the text "1" look the same, and so do true and the text "true". Strings keep their leading zeros and spaces, and numbers are written exactly as in the JSON (12345678901234567890, 1.50 and 1e30 do not change). A spreadsheet program may still change a cell such as 01234 when it opens the file.
- Quoting and delimiter. Choose comma, semicolon or tab, and whether to write the header row. A value is wrapped in double quotes when it contains the delimiter, a quote, a line break, or spaces at either end, and quotes inside are doubled. Line breaks in the output are LF.
- Protect against spreadsheet formulas. On by default, under Advanced settings. Text values and headers that start with
=,+,-,@, a tab or a carriage return get an apostrophe in front, the approach OWASP recommends against CSV injection. This changes the exported text, so=1+1becomes'=1+1. Numbers in the JSON, and text that is itself a plain number such as -5, are not changed. It lowers the risk but does not promise safety in every spreadsheet program; turn it off if you need the text unchanged. - Byte order mark. Optional, off by default. It writes the three bytes that mark a file as UTF-8, which helps some spreadsheet programs show accents and non-English text correctly. The mark is invisible in the output box but is included when you copy or download.
Results, errors and the other tab
- Errors are never a quiet empty result. If the input cannot be converted you get an error and the output is cleared. The message says what is wrong, for example “Record 3 has 2 values, but record 1 has 3”, with the line and a Go to error button. Nothing is repaired or guessed. The first problem is shown; fix it and convert again.
- Out of date output. Nothing converts while you type. If you change the input or a setting afterwards, the output and summary are marked out of date until you press Convert again. Copy and Download always give the output you see, made with the settings shown in the summary.
- Use the output in the other tab. Moves a successful result into the input of the other direction, so you can check a round trip. Undo brings the previous input of that tab back, also after Clear, Import or Load Example.
- Files. Import a UTF-8 .csv, .tsv or .txt file for CSV, or a .json or .txt file for JSON. The file is read in your browser and not uploaded. Downloads are UTF-8 files named converted.json or converted.csv.
Limits
- 5 MB
- 100,000
- 500
Larger input, more rows or columns, or a result of more than 16,000,000 characters is refused with a message rather than cut. JSON can be nested at most 128 levels deep before it is refused, though only flat objects convert. Conversion runs in a background thread (a Web Worker), so the page stays responsive, and a newer conversion replaces an older one that is still running.
What happens to your data
Everything runs in your browser. Your CSV and JSON are not uploaded and are not sent to any server, and they are only read as text: never run as code or shown as HTML. They are not saved in the browser and not put in the page address. Refreshing or closing the tab discards them. See Privacy.
Not included
- Nested JSON: flattening, or nested values written as text
- Guessing numbers, dates, booleans or null in CSV
- Other text encodings than UTF-8, or Excel (.xlsx) files
- Automatic repair of malformed CSV or JSON
- Merging, filtering or sorting rows and columns
Frequently asked questions
Is my data uploaded?
No. It is converted in your browser. The site only delivers the page and its code.
Why are my numbers strings in the JSON?
On purpose. A CSV file has no types, and guessing would change values such as zip codes (01234) or long ids. Every value stays the text you wrote, and you decide what to convert afterwards.
Why was my nested JSON refused?
A CSV cell holds one value. Turning an object or array into columns or text means choosing names and a format, and this tool does not make that choice for you. Flatten the data first, or remove the nested keys.
Why did I get an error about the number of values in a record?
Every record must have as many values as the first. A missing or extra delimiter, an empty line, or a value with a delimiter in it that is not wrapped in quotes usually causes this. The error names the record and the line.
Auto-detect picked the wrong delimiter. What now?
Choose Comma, Semicolon or Tab yourself and press Convert again.
Why is there an apostrophe in my exported cells?
That is the formula protection. It marks text that starts with = + - @ as text so a spreadsheet does not run it as a formula. Turn it off under Advanced settings if you need the text unchanged.
Do I need an account?
No. The tool is free and needs no sign-in.