Developer & Data

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.

By EverySolve Editorial Team • Published: • Last updated: • 5 min read

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:

iduser.nameuser.rolebilling.citybilling.planactive
101Alice VermaAdminMumbai, MHProtrue
102Bob NairEditorBengaluru, KAFreefalse

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):

  1. 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".
  2. 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").
  3. 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

  1. Open the EverySolve JSON to CSV Converter. (If your JSON has syntax errors, validate it first in the JSON Formatter).
  2. Paste your JSON array (or an object containing a records array) into the input editor, or upload a .json file.
  3. Choose your preferred field delimiter (Comma , for standard US/UK spreadsheets, Semicolon ; for European regional Excel settings, or Tab \t for TSV).
  4. Click Convert to preview the generated CSV and download the .csv file directly from browser memory. After exporting, you can also deduplicate or trim rows using the CSV Cleaner.

Standards & Technical References

  • RFC 4180 — Common Format and MIME Type for Comma-Separated Values (CSV) Files — Internet Engineering Task Force (IETF) (Reference)
  • RFC 8259 — The JavaScript Object Notation (JSON) Data Interchange Format — Internet Engineering Task Force (IETF) (Reference)
About the EverySolve Editorial Team & Technical Verification:

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.

Editorial & Privacy Architecture → Spot an error? Suggest a correction →

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

← Back to All Guides Explore All Tools →