CSV and JSON converter
Paste CSV or JSON, or open a file, then choose the direction and delimiter. Commas, quotes and line breaks inside cells are handled by the usual CSV rules, and problems are reported with their row number. JSON to CSV gets data ready for Excel and spreadsheets, and CSV to JSON gets it ready for code and APIs.
Loading the tool…
Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.
How to use it
- Choose the direction: “CSV to JSON” or “JSON to CSV”.
- Paste the text or open a CSV, JSON or TXT file (up to 5 MB), or press “Load example”.
- Set the options: delimiter, whether the first row holds column names, number conversion, nested JSON handling and the BOM.
- Check the summary and notes: row and column counts and the row numbers that have a problem.
- Copy the output or download it as a file.
Example
The row 1002,Omar,AED,80,Dubai,"قال: ""شكرًا""" under the headers order,customer,currency,amount,city,note becomes an object with "order": "1002", "amount": "80" and "note": "قال: \"شكرًا\"". Note that 80 stays a string because number conversion is off by default, and the doubled quotes became single quotes.
In the other direction, {"id": 1001, "customer": {"name": "سارة", "city": "الرياض"}, "tags": ["سريع", "هدية"]} with “Flatten” gives the columns id, customer.name, customer.city, tags.0 and tags.1. With “JSON text”, customer stays in one cell containing {"name":"سارة","city":"الرياض"}.
Limits and caveats
- The limit is 5 MB per file or text. Measured in Chromium on a desktop computer: a 5 MB CSV file (about 70,000 rows) was converted and displayed in about 4 seconds. Anything over 200,000 characters is processed from memory and only the first 200,000 characters are displayed; copy and download include the full output.
- Files are read as UTF-8 by default. If a file is not UTF-8 you get a message saying so rather than garbled letters, and you can choose Windows-1256 for older Arabic Excel exports. Other encodings are not detected.
- JSON to CSV accepts an array of objects, an array of arrays, an array of simple values, or a single object. Arrays that mix these are refused, with the number of the offending item.
- When flattening, arrays are written by position (tags.0, tags.1), so arrays of different lengths produce many columns. A key that itself contains a dot, such as "a.b", shares a column with a nested object a that has a key b.
- null values and missing keys both become empty CSV cells and cannot be told apart afterwards. CSV does not keep data types.
- Completely empty CSV lines are skipped. A row with more fields than the header keeps its extra fields under the key __parsed_extra, with a warning.
- Number conversion turns 00123 into 123 and loses leading zeros, so leave it off for phone numbers, postcodes and product codes.
- In the text boxes, a line that mixes Arabic with numbers can look reordered on screen. That is how browsers display bidirectional text; the data itself is in the correct order when copied or downloaded.
Questions about this tool
Why does Arabic show as strange symbols when I open the CSV in Excel?
Excel assumes a legacy encoding unless the file starts with a byte order mark. Keep “Add a UTF-8 BOM” ticked (the default) and the three bytes EF BB BF are written at the start of the downloaded file, so Excel reads Arabic correctly. Programs that do not expect a BOM may treat it as part of the first header, so untick it if another program will read the file.
What is the difference between “Flatten” and “JSON text” for nested values?
Flatten opens nested objects and arrays into columns named like customer.city and tags.0, which suits spreadsheets. “JSON text” writes the nested value as text inside a single cell, which suits cases where you want to restore the structure later.
How are row numbers in the messages counted?
Records are counted from 1 and the header row counts as a row. A line break inside quotes does not start a new row, so the row number can differ from the line number in a text editor.
How do I convert JSON to CSV and open it in Excel?
Choose “JSON to CSV”, paste the text or open the file, and download the result with “Add a UTF-8 BOM” left on so Excel reads Arabic correctly. [{"name":"سارة","city":"الرياض"}] becomes two columns, name and city, and one row: سارة,الرياض. Nested objects are opened into dotted columns such as customer.city by the default “Flatten” option.
How do I convert CSV to JSON with numbers as numbers?
Choose “CSV to JSON” and turn on “Convert numbers and true/false to JSON values”, so the value "80" becomes the number 80. It is off by default because it drops leading zeros (00123 becomes 123), which breaks phone numbers and postcodes. The delimiter is detected automatically, or you can pick comma, semicolon, tab or pipe yourself.
