Commas, quotes, and newlines
Convert CSV and JSON
CSV is a table in text. This page parses quotes and doubled quotes, then prints JSON, or walks a JSON array and prints CSV.
With the header row on, the first CSV row becomes object keys and later rows become objects. Without it, the result is an array of arrays. JSON for the other direction must be an array of objects or an array of arrays. Cells that contain a comma, a quote, or a newline are quoted, and quotes inside a cell are doubled. A blank line at the end is kept only when it has cells.
The table stays in this tab. It is not uploaded.
This tool runs in your browser. Turn on JavaScript to use it.
A comma inside a city name
The quotes belong to CSV. They are not part of the city.
- CSV
- name,city Ada,"New York"
- JSON
- [{"name":"Ada","city":"New York"}]
How to use it
- 1Paste CSV and convert it, or paste a JSON array.
- 2Turn the header option off when the first row is data.
- 3Copy the result.
Good to know
- The separator is a comma, not a semicolon.
- Numbers in CSV become strings.
- More than 5000 rows is rejected.
Questions
Will numbers stay numbers?
CSV has no types. Every cell becomes a string. JSON numbers become text on the way to CSV.
What about a semicolon file?
This page splits on commas. A semicolon-separated file will stay in one column.
Can a cell contain a newline?
Yes, when the cell is quoted.
Related tools
- Format and check JSON
JSON is a data format with strict commas, quotes, and no comments. This page parses what you paste and prints it again with an indent, or on one line.
- Convert JSON and YAML
YAML is easier to scan than a one-line JSON object, and JSON is what most programs parse. This page converts between them for a plain subset.
- Sort, trim, and count lines
Lists in a text box are awkward to clean by hand. This page trims, filters, sorts, or reverses the lines, and always shows the counts.