The fastest way depends on what tool you already have
Converting JSON to CSV means taking data structured as nested objects and flattening it into rows and columns. The method you choose depends on whether you want a one-time conversion, need to automate the process, or prefer to avoid writing code.
For a single file, an online converter or a spreadsheet program works fastest. For repeated conversions or large batches, a command-line tool or a programming language gives you more control. The trade-off is always between speed and flexibility — the easier the tool, the less you can customize the output.
Key Takeaways
- Online converters handle simple, flat JSON structures in seconds but may struggle with deeply nested data or large files.
- Spreadsheet programs like Excel and Google Sheets can import JSON directly if the structure is simple, but require manual setup for complex data.
- Command-line tools like jq (for JSON) paired with standard Unix tools give you precise control over which fields to extract and how to format them.
- Programming languages like Python and JavaScript are necessary when you need to transform data during conversion, such as combining fields or filtering rows.
- The structure of your JSON matters more than the size — flat objects convert easily, but nested arrays and objects require flattening logic.
Using an online converter for quick, simple files
Online JSON-to-CSV converters work best when your JSON is flat — meaning each object contains only simple values, not nested objects or arrays. Sites like CloudConvert, Convertio, and JSON to CSV converters (search for the exact phrase) accept a file or pasted text and output a downloadable CSV in seconds.
The limitation is that they handle nesting inconsistently. If your JSON contains an array of objects inside another object, the converter may skip it, flatten it unpredictably, or create extra columns you did not expect. Test with a small sample of your actual data before converting a large file.
These tools are free and require no installation, but they upload your data to someone else's server. If your JSON contains sensitive information, this is not the right choice.
Importing JSON into Excel or Google Sheets
Both Excel and Google Sheets can import JSON, though the process differs and works best with simple structures. In Google Sheets, use the IMPORTDATA function if your JSON is hosted at a URL, or paste the raw JSON and use IMPORTJSON (a custom function you can find in the Sheets add-on gallery). In Excel, use Get Data (in the Data tab) and select From File, then choose your JSON file.
Once imported, the data appears as a table. You can then save the sheet as a CSV file using File > Download (in Sheets) or Save As (in Excel). The spreadsheet will flatten the structure automatically, but the result depends on how nested your JSON is — deeply nested data may create columns with confusing names or duplicate rows.
This method works well for data that is already close to tabular form, such as a list of user records where each user has a few properties. It does not work well if you need to pick specific fields, combine data from multiple nested levels, or filter rows during conversion.
Using jq and command-line tools for precise control
jq is a command-line tool that reads JSON and outputs text in any format you choose, including CSV. If you have a Mac or Linux machine, jq is often already installed; on Windows, you can download it from the jq website. The basic syntax is jq -r '[.field1, .field2] | @csv' input.json > output.csv, where you list the fields you want in square brackets.
For example, if your JSON contains user records like {"name": "Alice", "email": "alice@example.com", "age": 30}, the command jq -r '[.name, .email, .age] | @csv' users.json > users.csv extracts those three fields and writes them as CSV rows. The -r flag tells jq to output raw text instead of JSON-formatted strings.
jq is powerful because it lets you filter, transform, and reshape data before converting. You can extract only records where a field matches a condition, combine multiple fields into one, or reorder columns. The learning curve is steeper than a graphical tool, but the control is worth it for repeated conversions or complex data.
If your JSON is nested — for example, an array of objects inside another object — you can use jq to flatten it. The command jq -r '.users[] | [.name, .email] | @csv' extracts the users array, loops through each object with [], and outputs the selected fields as CSV.
Writing a Python script for automation and transformation
Python is the best choice if you need to convert JSON to CSV regularly, transform the data during conversion, or handle files too large for a browser. The built-in json and csv modules make this straightforward.
A basic script looks like this:
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', 'age']) writer.writeheader() writer.writerows(data)
This reads a JSON file containing a list of objects, writes the specified fields to a CSV file, and includes a header row. You can modify it to filter rows, combine fields, or handle nested data. For nested JSON, you would loop through the structure and extract the fields you need before writing them to CSV.
If you are not familiar with Python, the learning curve is gentler than jq, and you can find many examples online for specific transformations. If you use Python regularly for data work, this approach scales better than any graphical tool.
Handling nested and complex JSON structures
The real challenge in JSON-to-CSV conversion is that JSON can be deeply nested while CSV is flat. A JSON object might contain arrays of objects, which contain more arrays — there is no single "right" way to flatten this into rows and columns.
The most common approach is to decide which level of nesting becomes your rows. For example, if your JSON is a list of customers, each with an array of orders, you might create one row per order (repeating the customer name on each row) or one row per customer (combining all orders into a single field). Which you choose depends on what you plan to do with the CSV.
Online converters and spreadsheet imports make this decision for you, which is why they sometimes produce unexpected results. Command-line tools and programming languages let you control it explicitly. If you are not sure how to flatten your data, start by examining the JSON structure in a text editor and sketching out what your CSV should look like.
Comparing the methods side by side
| Method | Best for | Speed | Control | Learning curve |
|---|---|---|---|---|
| Online converter | One-time, simple files | Seconds | Low | None |
| Excel or Google Sheets | Simple data, visual editing | Minutes | Medium | Low |
| jq command-line | Repeated conversions, complex filtering | Seconds | High | Medium |
| Python script | Automation, data transformation | Seconds | Very high | Medium |
Frequently Asked Questions
What if my JSON file is too large for an online converter?
Most online converters have file size limits, usually between 5 and 50 MB. For larger files, use jq or Python. Both can process files much larger than your computer's memory by reading and writing in chunks. If you are not comfortable with command-line tools, try importing the JSON into a spreadsheet program, which often handles larger files than online converters.
Can I convert CSV back to JSON?
Yes, using the same tools in reverse. Online converters often work both directions. In Python, use the csv module to read and the json module to write. In jq, you would read CSV (which is trickier) and output JSON. For most purposes, converting CSV to JSON is less common because CSV loses the nested structure that JSON preserves.
What happens to empty fields or null values?
Online converters and spreadsheet programs usually leave empty cells blank. jq and Python let you control this — you can output the word "null", leave it blank, or substitute a default value. Check your tool's documentation if you need specific handling of missing data.
Do I need to install anything to use jq?
On Mac and Linux, jq is often pre-installed or available through a package manager. On Windows, download the executable from the jq website and add it to your system path, or run it from the folder where you downloaded it. Python requires installation from python.org, but both are free and widely used.
How do I know which fields to extract from nested JSON?
Open your JSON file in a text editor and look at the structure. Identify which level of nesting contains the data you want as rows, then list the field names you need. If you are unsure, start with a small sample and test the conversion with one or two fields before running it on the full file.