CSV / JSON Converter
Convert CSV to JSON or JSON back to CSV in your browser, with column headers mapped to object keys and copyable output.
What it does
- CSV to JSON with header-to-key mapping
- JSON to CSV with the union of all keys as columns
- Header row on: objects. Header row off: arrays
- Quoted fields, embedded commas and line breaks handled
- Runs locally, no data leaves the browser
This converter works in both directions in a single screen: paste CSV in the left panel and click CSV → JSON, or paste a JSON array in the right panel and click JSON → CSV. Each panel is both an input and an output, so you can convert, edit, and convert back without switching pages. The parsing is done by the Rust csv and serde_json libraries compiled to WebAssembly, so a spreadsheet export full of customer data is processed inside your browser tab and never uploaded.
If you only need one direction, the dedicated pages lock the tool to it: CSV to JSON converter and JSON to CSV converter.
How the CSV to JSON conversion works
- Paste comma-separated data into the CSV panel, for example an export from Excel, Google Sheets or a database client.
- Leave Has headers checked if the first line holds column names. Uncheck it if the file starts directly with data.
- Click CSV → JSON. The JSON panel fills with a pretty-printed array, which you can copy with one click.
With the header row on, each line becomes an object whose keys are the column names: name,age followed by Alice,30 gives [{"age": "30", "name": "Alice"}]. With the header row off, each line becomes an array of values: [["Alice", "30"]]. Keys inside each object are written in alphabetical order.
How the JSON to CSV conversion works
The JSON input must be an array of objects, such as [{"id": 1, "email": "a@example.com"}, {"id": 2, "role": "admin"}]. The tool collects every key that appears in any object, not only in the first one, and uses that union as the header row. A record that lacks a key simply gets an empty cell in that column, so no column silently disappears because the first record was incomplete. Columns are sorted alphabetically.
- Strings are written as-is, and quoted automatically when they contain a comma, a quote or a line break.
- Numbers and booleans are written as text:
1,true. - null is written as the word
null. - Nested objects and arrays are written as compact JSON inside the cell, for example
[1,2]. Flatten nested data first if you need one column per sub-field.
A single object (not wrapped in an array) is rejected with the message "JSON must be an array of objects". Wrap it in square brackets to convert it as one row.
Edge cases worth knowing
- Delimiter: the parser expects commas. A semicolon-separated file (common in French and German Excel exports) or a tab-separated file is read as one column. Export again with commas as the separator. For a tab-separated file, convert it first with the TSV to CSV converter.
- Quoted fields: values like
"Smith, John"or a quoted value spanning several lines are parsed correctly, following standard CSV quoting. - Ragged rows: every row must have the same number of fields as the first. A row with an extra field stops the conversion with an error that names the line, which is useful for finding a stray comma.
- Byte order mark: the invisible BOM that Excel adds to UTF-8 CSV files is stripped, so your first column name stays clean.
- Types: every CSV value becomes a JSON string.
30stays"30". CSV has no type information, and guessing would turn ZIP codes like01234into the number 1234.
Typical uses
- Turning a spreadsheet export into fixture data or a seed file for an application.
- Preparing a JSON payload for an API that accepts bulk records.
- Flattening an API response into CSV so a colleague can open it in a spreadsheet.
- Checking quickly why an import fails, thanks to the line-numbered error on malformed rows.
Compared with a spreadsheet or a script
Excel and Google Sheets open CSV but do not export JSON without an add-on or a script. In Python, csv.DictReader plus json.dumps does the job in a few lines, and jq or Miller handle it on the command line. This page is the fastest option when you need a one-off conversion without writing code, and it keeps the same privacy as a local script because nothing is sent over the network.
Privacy for spreadsheet data
CSV exports are usually the rawest form of business data: customer lists with emails and phone numbers, invoices, payroll lines, CRM dumps. Uploading them to an online converter means a copy of personal data now lives on a server you do not control. Here the conversion runs in WebAssembly in the page itself, with no request carrying your data. Close the tab and nothing remains.
Frequently asked questions
- Is my CSV file uploaded anywhere?
- No. You paste the data into the page and the conversion runs locally in your browser through WebAssembly. No network request contains your data.
- Why are my numbers in quotes in the JSON?
- CSV stores everything as text, so the converter keeps every value as a JSON string rather than guessing. This protects values like ZIP codes, phone numbers and IDs with leading zeros. Convert specific fields to numbers in your own code if needed.
- My CSV uses semicolons. Can I convert it?
- Not directly: the parser splits on commas. Replace the separator first, or export the file again with commas as the delimiter.
- What happens when JSON objects have different keys?
- All keys found in any object become columns. Missing values become empty cells, so no data is dropped.
- Can I convert nested JSON to CSV?
- Yes, but nested objects and arrays end up as JSON text inside a single cell. CSV is flat, so for one column per nested field you need to flatten the structure before converting.
- Why did the conversion fail with "found record with 3 fields"?
- One row has more or fewer fields than the header. Usually it is an unquoted comma inside a value. The error message gives the line number to check.
- Can I upload a .csv file instead of pasting?
- The tool works on pasted text. Open the file in a text editor, copy its content, and paste it. To browse a large CSV as a table first, use the CSV viewer.