JSON to CSV

Flatten JSON arrays of objects into comma-separated values.

CSV output

Overview

JSON to CSV converts JSON object arrays into Comma-Separated Values (CSV) format, enabling data to be opened and analyzed in spreadsheet software like Excel and Google Sheets. It automatically extracts all object keys as headers and converts each object into a CSV row, perfect for data export, report generation, and data analysis.

Use Cases

Data Export and Reporting

JSON data returned by APIs often needs to be presented in tabular form for non-technical users. After converting JSON to CSV, data can be opened in Excel or Google Sheets, facilitating report creation, charts, and pivot tables.

Database Migration

When migrating data between different systems, CSV is a universal intermediate format. Convert JSON API responses or database exports to CSV for easy import into SQL databases, NoSQL systems, or other data warehouses.

Customer Data Sharing

When sharing data with clients or partners, CSV format is more accessible than JSON. Sales data, user lists, product catalogs can all be converted to CSV for easy sharing.

Data Analysis Preparation

Data analysts and data scientists frequently need to convert API data to tabular format for analysis in Python (Pandas), R, or statistical software. CSV is the standard input format for these tools.

How to Use

  1. Paste JSON Array

    Paste a JSON array of objects into the input field. Each object in the array should have the same key structure, which will become the CSV column headers.

  2. Execute Conversion

    Click the "Convert to CSV" button. The tool automatically identifies all unique keys as columns and converts each JSON object into a CSV row, displaying row count, column count, and header fields.

  3. Export and Use

    Copy the generated CSV content to paste directly into Excel, Google Sheets, or save as a .csv file for use in other applications.

Frequently Asked Questions

How is the order of JSON object keys handled?

CSV column order is based on the key order in the first JSON object, then any new keys appearing in subsequent objects are added. This ensures all data is included while maintaining consistent column ordering.

What if objects contain nested structures?

Nested objects and arrays are converted to their JSON string representation. For example, {"address": {"city": "Beijing"}} will appear as a string of the entire nested object in the CSV. It's recommended to flatten complex structures first or use specialized data processing tools.

How are commas and quotes handled in CSV?

Values containing commas, quotes, or newlines are automatically enclosed in double quotes, and internal quotes are escaped (doubled). This complies with the CSV standard (RFC 4180), ensuring data displays correctly in spreadsheet software.

Can empty arrays or empty objects be converted?

Empty arrays generate CSV with no data rows (headers only). Arrays containing empty objects generate empty rows. Completely empty input displays an error message.

Can converted CSV be converted back to JSON?

Yes, but some information may be lost, especially nested structures and data type information. Numbers might be treated as strings, and nested objects are flattened to string representations. CSV to JSON conversion requires additional data type inference.

Related Tools

Concept Notes

Flattening structure for rows and columns

CSV headers derive from the union of object keys; inconsistent shapes create sparse columns that spreadsheet tools may misinterpret. Nested objects and arrays get stringified, so flattening or mapping those fields before export produces cleaner tables and avoids losing meaning when non-tabular JSON is forced into a row/column model.

External Resources