How to Convert JSON to CSV for Spreadsheets and Data Analysis
JSON is convenient for applications and APIs, while CSV is often easier to inspect in spreadsheet software. A reliable conversion starts by deciding how each JSON field should become a column.
An array of objects is usually the easiest JSON structure to convert: each object becomes a row and its keys become column headers. Nested objects and arrays need an explicit flattening rule before export.
Identify the JSON structure
JSON represents objects, arrays, strings, numbers, booleans, and null values. CSV represents a flat table, so conversion is straightforward only when the JSON data already resembles rows and columns.
| JSON shape | Conversion approach | What to watch |
|---|---|---|
| Array of objects | One object per row; object keys become column names | Missing or extra keys across objects |
| Single object | Choose whether properties should become columns in one row or key/value rows | Different tools may offer different layouts |
| Nested object | Flatten into dotted paths such as address.city | Nested names can collide with existing keys |
| Array inside a row | Join values with a documented delimiter or create a separate table | Commas inside a cell must be escaped properly |
| Mixed types | Choose a consistent column representation | Spreadsheet applications may reinterpret dates and numbers |
Before converting a large payload, inspect a few records and decide what each column should mean. A conversion tool cannot guess the correct reporting model for every nested structure.
Convert a simple array of objects
Consider this small JSON dataset:
[
{"name": "Ava", "city": "Cairo", "score": 9},
{"name": "Noah", "city": "London", "score": 7}
]
Each object has the same three keys, so the CSV output can use those keys as the header row:
name,city,score
Ava,Cairo,9
Noah,London,7
- Check that the JSON is valid using a JSON Validator.
- Open the JSON to CSV Converter and paste or load the non-sensitive JSON data.
- Review the detected column names, row count, and treatment of nested values or missing keys.
- Convert and download the CSV file.
- Open the downloaded file in the intended spreadsheet application and confirm that columns, characters, and values appear correctly.
For spreadsheet imports, UTF-8 text is usually the safest default for names and international characters. Some spreadsheet applications use locale-specific delimiters; if all data appears in one column, use the import dialog to choose the correct delimiter rather than changing the data blindly.
Handle nested values and missing fields
Nested JSON requires a mapping decision. For example, an object with an address property could become one text field or several columns such as address.city and address.postcode. Choose names that are unambiguous and stable for later analysis.
{
"id": 42,
"customer": {"name": "Ava", "city": "Cairo"},
"tags": ["new", "priority"]
}
Missing keys, explicit null values, and empty strings are not the same thing. A blank CSV cell may not preserve the difference between them. If that distinction matters to your analysis, add an explicit status column or keep the original JSON alongside the exported table.
Protect commas, quotes, and line breaks
CSV fields may contain punctuation that could be mistaken for separators. A correct CSV writer quotes such fields and escapes an embedded quote by doubling it. For example:
name,comment
Ava,"Likes apples, pears, and plums"
Noah,"Said ""check again"" before shipping"
Do not build a CSV by joining raw strings with commas unless the values are guaranteed not to contain commas, quotation marks, or line breaks. Use a standards-aware converter, then open the output in the target application to confirm it parsed as intended.
Validate the export before using it
- Compare the input record count with the number of output rows.
- Check the first and last records, as well as records with missing or nested fields.
- Confirm that headers are unique and descriptive.
- Inspect international characters, multiline text, and values containing commas or quotes.
- Check whether spreadsheet software has automatically changed identifiers, dates, leading zeros, or long numbers.
- Keep the original JSON if you may need to reproduce or audit the export.
Use the CSV to JSON Converter to test a round trip on a small sample. A round trip is a useful check, but it does not guarantee that every type distinction or nested structure will be preserved by CSV.
Frequently asked questions
What JSON structure is easiest to convert to CSV?
An array of objects with consistent keys is usually the easiest. Each object becomes a row and keys become column headers.
Can CSV preserve nested JSON objects?
Not directly. Nested objects and arrays must be flattened, serialized into a single field, or separated into related tables. The conversion rule should be explicit.
Why does my CSV open in one spreadsheet column?
The spreadsheet may be using a different delimiter or import locale. Use the import dialog to select the delimiter and character encoding that match the file.
Does a JSON-to-CSV conversion preserve every data type?
No. CSV is a text-based flat format and does not natively preserve JSON-specific types or nested structure. Keep the source JSON when those distinctions matter.
References and related tools
Use these resources to continue checking the details or to complete the task described in this guide.
This guide is intended for practical learning and should be checked against the requirements of your own workflow. To suggest a correction, visit our Contact page or review our Editorial Policy.