What Are CSV and JSON?
CSV (comma-separated values) and JSON (JavaScript Object Notation) are the two most common plain-text data formats on the web, and they model data very differently. CSV is a table: rows of cells separated by commas, usually with a header row naming the columns. It is what spreadsheets export, what databases dump, and what your bank's transaction history arrives as. JSON is a tree: objects with named keys whose values can be strings, numbers, booleans, arrays, or nested objects. It is what APIs return, what configuration files use, and what modern pipelines exchange between services. Converting between them means mapping a flat grid onto a nested structure — or the reverse — and doing that by hand for anything larger than a toy example is slow and error-prone.
Why Convert Between Them?
- Spreadsheet to API: product catalogs, user lists, and inventory exported from Excel or Google Sheets need to become JSON objects before they can be posted to an API or loaded into an application.
- API responses to spreadsheets: JSON from a REST endpoint is often easier to review, sort, and share after flattening to CSV for a spreadsheet.
- Database exports and imports: many databases and admin tools accept CSV for bulk imports, while the same data model lives in JSON elsewhere.
- Data analysis: analysts who live in spreadsheets can consume JSON payloads by converting them to a tabular form first.
- Testing and debugging: inspecting a JSON payload as a table, or preparing a CSV fixture for a test suite that consumes JSON, are daily chores for developers.
How CSV → JSON Works Here
The CSV side follows RFC 4180, the standard for comma-separated data. Fields wrapped in double quotes
may contain commas and newlines; a doubled quote ("") inside a quoted field represents a
literal quote; CRLF, CR, and LF line endings are all accepted; a UTF-8 BOM is stripped; and a trailing
newline does not create a phantom empty row. The first row becomes the object keys, so
name,age turns into keys named name and
age. Every value is kept as a string — CSV has no types — and rows are handled
leniently: a row with fewer cells omits the missing keys, extra cells are ignored, and rows that are
entirely empty are dropped. The result is pretty-printed with two-space indentation, ready to paste
into code or a file.
How JSON → CSV Works Here
The JSON side accepts an array of objects or a single object. Keys are collected in order of first
appearance across all rows, so objects with different key sets still produce a sensible unified
header. Numbers and booleans become their plain text form, null and missing keys become
empty cells, and objects or arrays are flattened into compact JSON inside a single cell. Any cell
containing a comma, quote, or newline is quoted with doubled-quote escaping, so the output is always
valid CSV that Excel and other tools will read back correctly. Invalid JSON, an empty array, or a
non-object element produces a clear error message instead of garbage.
Step-by-Step: One Table, Both Directions
Start with the CSV name,age then Ada,36 then Bob,41.
Pasting it into the left box produces the JSON array
[{"name": "Ada", "age": "36"}, {"name": "Bob", "age": "41"}] — two objects keyed by the header
row, values still strings. Now paste that JSON into the right box and the left side returns to
exactly the original CSV, because the round trip is lossless for simple string tables. Add a nested
field and the behavior changes: an object like
{"name": "Ada", "meta": {"team": "eng"}} becomes the CSV row
name,meta then Ada,"{"team":"eng"}"
— the nested part survives, but as a flattened JSON blob rather than a structured column.
Quoted fields are where the parser earns its keep. Paste the row
name,note then "Ada","said ""hi"""
and the note cell comes back as said "hi" — the doubled quotes inside the field are
unescaped, while the quotes that wrapped the field are discarded. Add a newline inside a quoted
field and it survives intact too, which is how multi-line addresses and free-form notes survive a
spreadsheet export. These are exactly the cases where a naive split-on-comma converter produces
broken JSON, and exactly why this tool implements the full RFC 4180 rule set.
Reference Table
| Input | Output |
|---|---|
| name,age Ada,36 | {"name":"Ada","age":"36"} |
| name,city "Ada, Lovelace",London | {"name": "Ada, Lovelace", "city": "London"} |
| [{"a":1},{"b":2}] | a,b 1, ,2 |
| [{"n":{"k":[1,2]}}] | n "{"k":[1,2]}" |
Paste any row into the tool to confirm — the third row shows how missing keys become empty cells, and the fourth shows nested JSON flattened with quotes escaped.
Common Pitfalls
- Types are not preserved: "36" in CSV is a string; if the JSON needs a number, retype it after converting or convert from JSON.
- Nested data flattens: JSON trees become JSON-blob cells in CSV — acceptable for interchange, wrong for deep analysis.
- Duplicate headers collide: two columns with the same name mean the later value wins in the JSON object.
- Non-comma delimiters: semicolon or tab exports must be converted to commas first.
- Missing trailing newline: fine here (this parser handles it), but some tools emit an extra empty row; this one does not.
- BOM corruption: Excel-exported files may carry a BOM; this tool strips it so header keys stay clean.
Troubleshooting
The JSON Side Shows an Error for Valid-Looking CSV
Check the delimiter first — a semicolon-separated file will fail or produce a single-column table. Also check for unclosed quotes: a field that opens with a quote but never closes swallows the rest of the file.
The CSV Side Shows an Error for Valid-Looking JSON
The converter needs an array of objects or a single object. Arrays of primitives, strings, numbers, and null values are rejected with a clear message — wrap the data in objects first.
Very Large Files
This converter is built for interactive use — pasted data, exports up to a few megabytes — and runs entirely in the browser, so extremely large files can slow the tab. For a 100,000-row export, consider converting in chunks or using a command-line tool instead; for everyday spreadsheet and API work, this page is instant.
My Headers Look Corrupted
Trim stray spaces around header names — a header of name produces a key with spaces.
This tool trims header whitespace automatically, so check your source file for invisible characters
if keys still look wrong.