How to Convert JSON to CSV for Excel and Spreadsheet Analysis
Learn how nested JSON objects and arrays are flattened into tabular CSV columns, how RFC 4180 quote escaping works, and how to avoid Excel import glitches.
REST APIs, NoSQL databases, and webhook logs almost universally exchange data in JSON (JavaScript Object Notation). Finance teams, operations managers, and spreadsheet analysts, however, need flat rows and columns in CSV (Comma-Separated Values) to build pivot tables in Microsoft Excel or Google Sheets.
Because JSON is hierarchical (supporting nested objects and arrays) while CSV is strictly two-dimensional, converting JSON to CSV cleanly requires key flattening and proper delimiter escaping.
How Nested JSON Keys Are Flattened Into CSV Columns
Consider an array of customer records returned by an API:
[
{
"id": 101,
"user": { "name": "Alice Verma", "role": "Admin" },
"billing": { "city": "Mumbai, MH", "plan": "Pro" },
"active": true
},
{
"id": 102,
"user": { "name": "Bob Nair", "role": "Editor" },
"billing": { "city": "Bengaluru, KA", "plan": "Free" },
"active": false
}
]
If a naive script simply calls Object.values() on each top-level object, the user and billing columns end up containing useless [object Object] strings. A proper JSON-to-CSV converter traverses nested objects recursively and joins parent and child property names using dot notation:
| id | user.name | user.role | billing.city | billing.plan | active |
|---|---|---|---|---|---|
| 101 | Alice Verma | Admin | Mumbai, MH | Pro | true |
| 102 | Bob Nair | Editor | Bengaluru, KA | Free | false |
RFC 4180 Escaping Rules That Prevent Broken Columns
Notice that billing.city in the example above contains a literal comma (Mumbai, MH). Under RFC 4180 (the standard specification for CSV files):
- Fields Containing Commas or Newlines: Any string value containing the active delimiter (
,) or a line break (\n) must be wrapped in double quotes:"Mumbai, MH". - Fields Containing Double Quotes: If a string value itself contains a double quote (e.g.,
15" Laptop), the internal quote is escaped by doubling it ("15"" Laptop"). - Heterogeneous Schemas: In NoSQL exports, Object #2 might include an optional key (
couponCode) that was absent on Object #1. The converter must scan all records in the array first to build a complete superset of column headers so columns never shift out of alignment.
Step-by-Step: Converting JSON to CSV in EverySolve
- Open the EverySolve JSON to CSV Converter. (If your JSON has syntax errors, validate it first in the JSON Formatter).
- Paste your JSON array (or an object containing a records array) into the input editor, or upload a
.jsonfile. - Choose your preferred field delimiter (Comma
,for standard US/UK spreadsheets, Semicolon;for European regional Excel settings, or Tab\tfor TSV). - Click Convert to preview the generated CSV and download the
.csvfile directly from browser memory. After exporting, you can also deduplicate or trim rows using the CSV Cleaner.
Standards & Technical References
Verified against RFC 8259 (JSON) and RFC 4180 (Common Format and MIME Type for CSV Files) serialization rules. EverySolve guides are written and maintained by our engineering and editorial team to document exact formulas, file-format standards, and browser-based workflows.
Frequently Asked Questions
What if my root JSON is a single object instead of an array of objects?
Many API responses wrap the data array inside a metadata envelope such as { "status": 200, "data": [ ... ] }. The converter either extracts the primary array or treats a single flat object as a 1-row CSV table.
Why does Excel sometimes split my CSV into one single column when I double-click it?
In several European and Latin American Windows locales, Excel expects a semicolon (;) rather than a comma (,) as the list separator because commas are reserved as decimal points. Selecting Semicolon as the delimiter or importing via Data > From Text/CSV resolves this.
Are my API payloads uploaded to a backend server during conversion?
No. JSON parsing, key flattening, and CSV serialization run locally in your browser's JavaScript engine, keeping customer records and API responses private.
Related Online Tools
-
JSON to CSV Converter
Flatten JSON arrays and nested objects into RFC 4180 compliant CSV spreadsheet rows using dot-notation column headers.
-
JSON Formatter & Validator
Format, validate, prettify, and minify raw JSON string data with line error highlights.
-
CSV Data Cleaner & Sanitizer
Sanitize CSV datasets by removing duplicate rows, trimming cell whitespace, stripping blank lines, and normalizing RFC 4180 quotes.
-
JSON Schema Validator
Validate JSON documents and schemas online with error reporting.
Related Guides & Tutorials
-
How to Format, Pretty-Print, and Debug Broken JSON Data
Turn unreadable single-line API payloads into indented JSON trees, minify payloads for production transit, and fix the 5 most common RFC 8259 syntax errors.
-
How to Clean, Deduplicate, and Sanitize Messy CSV Spreadsheets
Prepare CRM exports, mailing lists, and financial CSV files by removing duplicate rows, trimming invisible whitespace, and preventing spreadsheet formula errors.