What JSON and CSV are, and why you might convert between them
JSON is a text format that stores data in nested layers — think of it as a filing system where information can be grouped inside other information. CSV (comma-separated values) is a flat list format where each row is a record and each column is a field. JSON is common in web applications and APIs; CSV is what spreadsheet programs like Excel and Google Sheets understand natively.
You convert JSON to CSV when you want to analyze data in a spreadsheet, back it up in a more portable format, or share it with someone who works in Excel rather than code. A JSON file from a web service, a downloaded data export, or an app backup often needs to become a CSV file before you can sort it, filter it, or store it alongside other documents.
The conversion process depends on how complex your JSON is. straightforward, flat JSON (where each record has the same fields at the top level) converts easily. Nested JSON (where data lives inside other data) requires you to decide which layers to flatten or which nested values matter most.
Key Takeaways
- Online converters like CloudConvert and Convertio handle JSON to CSV conversion without installing software, though you should not use them for sensitive personal data.
- Spreadsheet programs like Excel and Google Sheets can import JSON directly if the structure is straightforward and flat, then you save as CSV.
- Command-line tools like jq (on Mac and Linux) or PowerShell (on Windows) give you control over which fields to include and how to flatten nested data.
- For large files or repeated conversions, a Python script using the json and csv libraries takes a few minutes to write and runs reliably on any computer.
Using an online converter for quick, one-time conversions
Online JSON to CSV converters work in your browser with no installation. Go to CloudConvert, Convertio, or Zamzar, upload your JSON file, select CSV as the output format, and read the result. These tools handle the conversion in seconds and work on any device.
The trade-off is privacy. Your file travels to a server you do not control. For public data or test files, this is fine. For anything containing names, addresses, financial information, or other personal details, use a local method instead — either a spreadsheet program, a command-line tool, or a script on your own computer.
If your JSON is nested (data inside data), online converters often flatten it automatically by combining field names with underscores or dots. Check the preview before downloading to see whether the result matches what you need.
Importing JSON into Excel or Google Sheets, then saving as CSV
Excel and Google Sheets can open JSON files directly if the structure is straightforward — meaning each record is at the top level and contains the same fields. Open Excel, go to File > Open, and select your JSON file. Excel will attempt to parse it and display it as a table. If the structure is flat, this usually works.
Google Sheets requires a different approach. Upload your JSON file to Google Drive, right-click it, select "Open with" > "Google Sheets". Google Sheets will import it as a spreadsheet. Again, this works best with flat JSON where every record has identical fields.
Once the data is in the spreadsheet, save it as CSV. In Excel, go to File > Save As, choose CSV (Comma delimited) as the format, and pick a location. In Google Sheets, go to File > read > Comma-separated values (.csv). The spreadsheet program handles the conversion automatically.
Using command-line tools for control over nested data
On Mac and Linux: The jq tool is built for transforming JSON. If you have it installed (or can install it via Homebrew), you can convert JSON to CSV in one line. Open Terminal and run a command like:
jq -r '.[] | [.name, .email, .phone] | @csv' input.json > output.csv
This tells jq to take each record, extract the name, email, and phone fields, format them as CSV, and write to output.csv. You choose which fields to include and in what order. For nested data, you can navigate the structure — for example, .user.name instead of just .name.
On Windows: PowerShell (built into Windows 10 and later) can do the same work. Open PowerShell and use a command like:
$json = Get-Content input.json | ConvertFrom-Json; $json | Select-Object name, email, phone | Export-Csv output.csv -NoTypeInformation
This reads the JSON file, converts it to PowerShell objects, selects the fields you want, and exports as CSV. Like jq, you control which fields appear and in what order.
Writing a Python script for repeated or complex conversions
If you convert JSON to CSV regularly or your data has nested structures that need custom handling, a Python script is reliable and reusable. Python is free and available on Mac, Linux, and Windows. Here is a basic script:
import json import csv with open('input.json') as f: data = json.load(f) with open('output.csv', 'w', newline='') as f: writer = csv.DictWriter(f, fieldnames=['name', 'email', 'phone']) writer.writeheader() writer.writerows(data)
Save this as convert.py, replace 'input.json' with your file name and 'name', 'email', 'phone' with your actual field names, then run python convert.py in Terminal or PowerShell. The script reads the JSON, writes a CSV with headers, and saves it.
For nested JSON, you can modify the script to extract only the fields you need or to flatten nested structures. Python's json and csv libraries are part of the standard installation, so no additional software is required.
Handling common problems during conversion
Missing or inconsistent fields: If some records have a field and others do not, CSV will show blank cells for missing values. This is normal and spreadsheet programs handle it correctly. If a field is missing from most records, you may want to exclude it from the conversion to keep the CSV cleaner.
Special characters and encoding: JSON files are usually UTF-8 encoded, and CSV files should be too. Most tools handle this automatically. If you open a CSV in Excel and see garbled characters, try opening it with Google Sheets instead, or re-save it in Excel with UTF-8 encoding (File > Save As > Tools > Web Options > Encoding).
Nested data that does not flatten: If your JSON has arrays or objects inside records, straightforward converters cannot flatten them automatically. You will need to decide: extract only the top-level fields, or use a command-line tool or script to pick specific nested values. For example, if a record contains an array of phone numbers, you might extract only the first one, or create multiple CSV rows per record.
Large files: Online converters may time out or refuse files over a certain size (often 100 MB). For large JSON files, use a command-line tool or Python script on your own computer, which has no file-size limit.
Choosing the right method for your situation
Use an online converter if the file is small, not sensitive, and the structure is straightforward. Use a spreadsheet program if you want to review the data before saving and prefer a graphical interface. Use a command-line tool if you need control over which fields to include and you are comfortable with Terminal or PowerShell. Use a Python script if you convert regularly, have nested data, or want a repeatable process you can run on any computer.
After conversion, open the CSV in a spreadsheet program to verify the data looks correct — check that columns are in the right order, no fields are missing, and special characters display properly. Then save a backup copy in a separate location before you delete the original JSON file.
Frequently Asked Questions
Can I convert JSON with nested data directly to CSV?
straightforward converters flatten nested data by combining field names, but you lose the structure. For example, a nested field like user.address.city becomes a single column called user_address_city. If you need only specific nested values, use jq, PowerShell, or a Python script to extract them first.
What if my JSON file is very large?
Online converters often have file-size limits. Use a command-line tool or Python script instead, which can handle files of any size on your own computer. These methods are also faster for large files because they run locally rather than uploading to a server.
Will the CSV file be the same size as the JSON file?
Usually smaller. CSV is more compact because it does not store field names repeatedly or use nested structure syntax. A JSON file with 1,000 records might become a CSV file 30 to 50 percent smaller, depending on how much nesting and repetition the JSON contains.
Can I convert CSV back to JSON?
Yes, using the same tools in reverse. Online converters, spreadsheet programs, command-line tools, and Python scripts all work in both directions. The CSV becomes flat JSON where each row becomes a record with the column headers as field names.
Do I need to install anything to use jq or PowerShell?
PowerShell comes with Windows 10 and later. jq is not pre-installed on Mac or Linux but is free and installs in seconds via Homebrew (Mac) or your package manager (Linux). Python is also free and available for all operating systems.