๐ CSVโJSON Converter
Convert CSV data into a JSON array, or a JSON array into CSV. Useful for turning spreadsheet data into a format your API or program can work with, or the reverse โ turning JSON data into something you can open in a spreadsheet app.
How to use
- Choose the direction: "CSV โ JSON" or "JSON โ CSV".
- Paste the data you want to convert (for CSV, the first row is treated as the header row).
- The converted result appears automatically below. Use the "Copy" button to copy it.
How the calculation works
CSV (comma-separated values) is a text table in which each line is a record and each comma-separated value is a field. This tool treats the first line as the header and turns each following line into a JSON object of header: value pairs, collected into a JSON array. The finer points of the format are documented in RFC 4180. A value containing a comma or line break is wrapped in double quotes, and a double quote inside a value is written as two ("") โ so "Tokyo, Shibuya" is read as a single value, not split at the comma. Converting JSON to CSV, the tool collects every key from every object in the array to build the header row. Columns for keys an object lacks are left empty.
Worked example
Converting this CSV name,age,address Tanaka,32,"Tokyo, Shibuya" Sato,28,Osaka results in [ {"name": "Tanaka", "age": "32", "address": "Tokyo, Shibuya"}, {"name": "Sato", "age": "28", "address": "Osaka"} ] Because "Tokyo, Shibuya" is quoted, it is kept as one value rather than split at the comma.
Things to be aware of
- All CSV values become strings. Adjust types afterwards if you need numbers or booleans.
- CSV saved from Excel in Japan may be Shift_JIS encoded. If text is garbled, re-save as UTF-8.
- When converting from JSON, a nested object becomes the literal string "[object Object]". Flatten nested data before converting.
- Line breaks inside quoted values are not supported โ keep each record on one line. Tab-separated (TSV) and semicolon-separated files are not supported either.
FAQ
Does this handle CSV fields with commas wrapped in double quotes?
Yes โ a field like "Tokyo, Shibuya" wrapped in double quotes is correctly treated as a single value, not split on the comma inside it.
For JSON โ CSV, what happens if objects have different keys?
The header row is built from the union of all keys across every object, and any object missing a given key gets an empty cell for it.
What should I do if the conversion fails?
For JSON โ CSV, the input needs to be a valid JSON array of objects โ check for syntax errors in your input.