Going Between JSON and CSV
Key points
- Format
- Convert
JSON is convenient for programs but a table suits people totalling things. Conversely, table data needs to be JSON to be handed to a program. Here is how to combine JSON formatted with Format and Validate JSON and the CSV conversion tool.
Flow (JSON → table)
- Format the JSON with this tool and check it's correct.
- Paste the tidy JSON into "JSON → CSV" of the CSV/JSON conversion tool.
- Convert to CSV, save and open in Excel.
Flow (table → JSON)
- Copy the Excel table and convert it with "CSV → JSON" in the CSV/JSON conversion tool.
- Format the resulting JSON with this tool and check it's correct.
- If needed, compress with "Make one line".
Checking that the JSON syntax is correct before converting prevents conversion errors.
JSON shapes that can be converted
A form where data with the same items is lined up is easy to convert to a table. Nested parts, when converted to a table, go into one cell as text.
Benefits of combining
- Conversion errors can be prevented in advance
- You can understand the data's structure through formatting before converting
- The converted JSON can be formatted at once
Good for
- Totalling API results in Excel
- Turning Excel data into web app data
- Managing configuration data as a table
Cautions
- What a table can handle is flat structures. Flatten deep nesting first, or extract the needed parts.
- The distinction between numbers and strings can change in conversion.
Example
Formatted JSON from an API with this tool to see its structure. Finding that the needed items were outside the nesting, it converted straight to CSV and could be totalled in Excel.
Common stumbling blocks
- Nested items go into one cell: reshape first.
- Date and number formats change: set the format on the Excel side.
- Garbled text: specify the encoding when opening in Excel.
Frequently asked questions
Which tool comes first?
On receiving JSON, first format and check. Then convert.
Summary
Use JSON formatting and checking in combination with conversion to CSV.
Use "Format and Validate JSON" (free)Tools that go well with this
- Convert CSV and JSON: Convert between CSV and JSON instantly.
- Convert Files and Base64: Convert between files and Base64 text.
- Remove Duplicate Lines and Sort a List: Remove duplicate lines and sort them.