# CSV to JSON Converter

> Turn a CSV export into JSON with real numbers and booleans, or an API's JSON into a spreadsheet-ready CSV with nested fields flattened, quotes escaped and an optional BOM for Excel.

- Page: https://codethatmoves.com/tools/dev/csv-json-converter/
- Site: Code That Moves
- Category: Developer tools
- Free, runs in the browser, nothing is uploaded (files you drop in stay on your device)
- Last checked: 2026-11-03

## What it does

- CSV to JSON as objects keyed by the header or as arrays of rows, indented, minified or as JSON Lines
- A table preview of the first 100 rows in both directions, with the row and column count
- Comma, semicolon, tab or pipe, with the delimiter detected automatically
- Quoted fields with commas, doubled quotes and line breaks, as in RFC 4180; spaces around fields trimmed by default, and # comment lines skipped on request
- Dot headers such as address.city nested back into objects
- Numbers, true, false and empty cells turned into JSON types; IDs with leading zeros stay text
- JSON or JSON Lines (NDJSON) to CSV with nested objects flattened to dot columns, and arrays kept as JSON or spread into tags.0, tags.1 columns
- Opened files that are not valid UTF-8 are read as Windows-1252, the encoding Excel on Windows uses; drag and drop works too
- Optional UTF-8 BOM and CRLF line endings for Excel, a CSV injection warning, copy and download

## How to use it

1. Pick the direction, then paste the data, or open or drop a .csv, .tsv, .json or .jsonl file. The result appears as you type.
2. For CSV, say whether the first row is a header and whether numbers and true/false should become JSON types. For JSON, choose whether nested objects become dot columns.
3. Copy the result or download it as a file. Read the notes under the result: they flag renamed headers, ragged rows and cells a spreadsheet might run as formulas.

## What it checks and why

CSV looks simple until a value contains the delimiter. RFC 4180 puts such a field in double quotes and writes a quote inside it twice, so "Okafor, Ada" is one field and "Mia ""Mimi"" Chen" holds a quoted nickname. A quoted field may even contain a line break. Splitting lines on commas breaks all three cases; this tool parses them properly.

Spreadsheets in many European locales save CSV with semicolons, because the comma is their decimal mark. The tool counts commas, semicolons, tabs and pipes on the first line, outside quotes, and picks the most common one. You can override it.

Type guessing is useful and risky. 91.5 should become a number, but 00123 is an ID and +44 20 7946 0000 is a phone number, and turning them into numbers loses the leading zero or the plus. The tool converts only plain numbers without leading zeros and up to 15 digits, which JavaScript can hold exactly.

Going the other way, a JSON API often returns nested objects. A flat CSV cannot hold them, so the tool writes address.city and address.zip as separate columns and keeps arrays as JSON text in one cell. Excel opens UTF-8 CSV without a byte order mark as an older code page and garbles accents, so there is an option to add the BOM.

A cell that starts with =, +, - or @ may run as a formula when the CSV is opened in a spreadsheet. OWASP calls this CSV injection. The tool counts such cells and warns you before you open data from someone else.

## Specs and sources

- [JSON Lines](https://jsonlines.org/)
- [RFC 4180: Common Format and MIME Type for CSV Files](https://www.rfc-editor.org/rfc/rfc4180)
- [RFC 8259: The JSON Data Interchange Format](https://www.rfc-editor.org/rfc/rfc8259)
- [OWASP: CSV Injection](https://owasp.org/www-community/attacks/CSV_Injection)

## Limits

- Everything is parsed in memory on the page, so very large files (hundreds of megabytes) can be slow or run out of memory, especially on a phone.
- Dates stay as text; the tool does not guess date formats, because 03/04/2024 means different days in different countries.
- Flattening uses dots in column names. If your keys already contain dots, nesting the CSV again cannot restore the original shape.
- Files over 1 MB are converted in full but not shown in the text box, which keeps typing responsive.
- Only the first array is used when the JSON is an object that holds several arrays.
- The output shown on the page is cut after 60,000 characters; Copy and Download always give the full result.

## Questions

### How do I convert JSON to CSV for Excel?

Choose JSON to CSV and tick the BOM option so Excel reads UTF-8 accents correctly. If your Excel uses a comma as the decimal mark, pick Semicolon as the delimiter so columns split properly.

### How do I convert JSON Lines (NDJSON) to CSV?

Paste or open the file with JSON to CSV selected. Text with one JSON object per line is read as JSON Lines automatically; going the other way, pick JSON Lines as the JSON output.

### How do I convert CSV to JSON?

Paste the CSV or open the file with CSV to JSON selected. With a header row each line becomes an object keyed by the column names; copy or download the JSON.

### Why does Excel show strange characters in my CSV?

Excel reads a UTF-8 CSV without a byte order mark as an older code page, so accents and other non-English letters come out garbled. Tick the BOM option when converting JSON to CSV.

### How are commas inside a value handled?

The value is wrapped in double quotes, and any quote inside it is doubled, as RFC 4180 describes. The parser reads such fields as one value, even when they contain line breaks.

### How do I convert nested JSON to CSV?

Keep Flatten ticked. Nested objects become columns with dot paths such as address.city, and arrays are written as JSON text inside one cell so nothing is lost.

### Why did my ID 00123 not become a number?

Numbers with leading zeros are kept as text on purpose, because they are usually identifiers or codes, and turning them into numbers would drop the zeros.

### Is my data uploaded?

No. Files never leave your device. The conversion runs in your browser and nothing you paste or open is sent to a server or stored.
