The team behind OnlineTools4Free — building free, private browser tools.
Published Apr 1, 2026 · 7 min read · Reviewed by OnlineTools4Free
Convert JSON to CSV: Flatten Data for Spreadsheets
Why Convert JSON to CSV?
JSON and CSV represent fundamentally different data models. JSON is hierarchical — objects nest inside objects, arrays contain other arrays, and data can be arbitrarily deep. CSV is flat — rows and columns, a two-dimensional grid. Converting between them is not a simple format swap; it requires decisions about how to map a tree structure onto a table.
The most common reason for this conversion is getting API data into a spreadsheet. Business analysts, data scientists, and non-technical stakeholders work in Excel and Google Sheets. When data comes from a REST API as JSON, someone needs to transform it into rows and columns. A sales team wants their CRM API data in a spreadsheet for filtering and pivot tables. A marketing team wants analytics data in a format they can chart. A finance team wants transaction records they can reconcile in their existing tools.
Databases are another destination. While modern databases handle JSON natively, many ETL (Extract-Transform-Load) pipelines still use CSV as an interchange format. Bulk import tools for PostgreSQL, MySQL, and data warehouses like BigQuery often accept CSV more efficiently than JSON, especially for large datasets.
Flattening Strategies
The core challenge is flattening nested structures. Consider a JSON object representing a customer order with nested shipping address and an array of line items. How should this become CSV rows?
Dot notation for nested objects: A nested property like address.city becomes a column header address.city. The object {"name": "Alice", "address": {"city": "Paris", "zip": "75001"}} flattens to columns name, address.city, address.zip. This is the most common approach and works well for consistently structured data with moderate nesting depth.
Denormalization for arrays: When a record contains an array of items, you have two options. First, create one row per array element, repeating the parent fields — an order with three line items becomes three rows, each repeating the order ID, customer name, and date. This is called denormalization and is standard for relational data analysis. Second, create numbered columns — item_1_name, item_2_name, item_3_name — which keeps one row per record but creates sparse columns when arrays have different lengths.
JSON-in-cell: For deeply nested or variable-structure data, sometimes the pragmatic approach is to leave certain fields as JSON strings within the CSV cell. A complex metadata object that varies per record might not flatten cleanly into fixed columns. Embedding it as a JSON string preserves all data while keeping the rest of the row flat.
Handling Edge Cases
Null and missing values: JSON distinguishes between a key with a null value, a key with an empty string, and a missing key entirely. CSV has no standard way to represent these differences. Most converters write an empty cell for all three cases. If the distinction matters for your downstream processing, document your convention (e.g., empty cell = null, literal string "null" = explicit null, space = empty string).
Data types: JSON has types — numbers, booleans, strings, null. CSV is typeless; everything is text. The number 42 and the string "42" look identical in CSV. Booleans true/false become text. Dates have no standard CSV representation. When importing CSV into a typed system, you will need to specify column types explicitly.
Commas and quotes in values: Values containing commas must be wrapped in double quotes in CSV. Values containing double quotes must have those quotes escaped by doubling them. Values containing newlines must also be quoted. A proper converter handles all of this automatically, but quick-and-dirty scripts often do not, producing broken CSV files.
Inconsistent schemas: Real-world JSON data from APIs often has inconsistent structure — some records have fields that others lack, array lengths vary, nested objects have different keys per record. A robust converter scans all records to determine the complete set of column headers before writing any rows, filling missing values with empty cells.
Converting CSV Back to JSON
The reverse conversion — CSV to JSON — is more straightforward because you are adding structure rather than removing it. Each row becomes a JSON object where column headers are keys and cell values are the values. The main decisions are data type inference (should "42" become a number or stay a string?) and whether to reconstruct nested objects from dot-notation headers.
Round-tripping JSON through CSV and back is generally lossy. Nested structures may not reconstruct exactly, data types are lost, null versus empty versus missing distinctions disappear, and array ordering within a denormalized table may not match the original. If you need lossless round-trip serialization, CSV is not the right intermediate format — use JSON Lines (JSONL) or keep the data in JSON throughout.
Convert JSON to CSV Online
Our JSON to CSV Converter transforms JSON arrays and objects into downloadable CSV files directly in your browser. Paste your JSON data or upload a file, and the tool automatically detects the structure, flattens nested objects using dot notation, and generates a CSV with proper headers. You can customize the delimiter, choose which fields to include, and handle arrays using your preferred strategy.
All conversion happens locally in your browser — no data is uploaded to any server. Use it for quick API data exports, preparing data for spreadsheet analysis, or generating CSV files for database imports.
JSON to CSV Converter
Convert JSON arrays to CSV format for spreadsheets and data analysis.
OnlineTools4Free Team
The OnlineTools4Free Team
We are a small team of developers and designers building free, privacy-first browser tools. Every tool on this platform runs entirely in your browser — your files never leave your device.
