JSON to CSV Converter

Convert JSON arrays into RFC 4180 compliant CSV tables and reverse CSV back to JSON. Supports nested object flattening, custom delimiters, and client-side execution.

JSON Input
Ready
625 B
CSV Output

CSV output will appear here...

All processing is done locally in your browserSupports nested JSON with flatten optionBidirectional: JSON and CSV

Conversion Workflow & Configuration

Step 1

Input Structured Payload

Paste your raw JSON array or CSV text, drag and drop .json / .csv files, or load the built-in sample dataset.

Step 2

Select Delimiter & Headers

Configure output parameters: toggle header rows, choose list delimiters (comma, semicolon, tab, pipe), and enable recursive object flattening.

Step 3

Inspect & Export Data

Toggle between plain text and the interactive tabular grid view, copy directly to your clipboard for Excel or Google Sheets, or download the serialized file.

Structural Paradigm: Hierarchical JSON vs Tabular CSV

JSON (RFC 8259) and CSV (RFC 4180) serve complementary roles in data engineering. JSON represents recursive, tree-structured data models with polymorphic schemas, while CSV represents two-dimensional relational tables. Converting between them requires resolving the structural impedance mismatch between arbitrary nesting and flat columnar grids.

DimensionJSON (RFC 8259)CSV (RFC 4180)Conversion Resolution
Data HierarchyRecursive tree with nested objects & arraysFlat 2D matrix (rows × columns)Recursive key flattening with delimiter notation
Schema RegularityPolymorphic: objects may contain varying keysRigid: all records share fixed column countUnion of all distinct keys across all records
Type SystemTyped: string, number, boolean, null, object, arrayUntyped: all values stored as raw character stringsLexical type inference during reverse parsing
Boundary DelimitingStructural brackets ({}, []) and key quotesCharacter delimiters (,, ;, \t) and newline recordsRFC 4180 quote wrapping when delimiters occur in data

Flattening Algorithms and Key Union Resolution

Real-world JSON data rarely arrives in uniform flat structures. API responses frequently nest metadata, related entities, and lists. To translate these structures into relational spreadsheets, the converter executes two critical transformations:

Recursive Dot-Notation Flattening

When flattening is enabled, nested object keys are recursively traversed and concatenated with a separator. An object with structure { "user": { "geo": { "lat": 40.7 } } } generates a single columnar header: user.geo.lat.

// Input JSON Object { "id": 101, "metrics": { "cpu": 45.2, "ram": 78.1 } } // Flattened Headers and Values id,metrics.cpu,metrics.ram 101,45.2,78.1

Polymorphic Key Union and Sparse Rows

In non-uniform datasets, some items lack certain properties. The converter compiles a global union of all unique keys encountered across every object in the array. Missing properties for a given row are cleanly emitted as empty fields, maintaining identical column counts across all rows.

// Heterogeneous Input [ { "id": 1, "email": "a@test.com" }, { "id": 2, "phone": "+1234" } ] // Output with Column Union id,email,phone 1,a@test.com, 2,,+1234
Array Serialization Strategy: Array values nested inside objects are handled based on their contents. Scalar arrays (strings, numbers, booleans) are joined into compact delimited strings (e.g., "reading, coding"). Arrays containing child objects are serialized as valid JSON strings to preserve their full multi-field structure within the host cell without corrupting tabular alignments.

RFC 4180 Escaping Rules and Delimiter Compatibility

The CSV format is standardized under RFC 4180. Because commas and line breaks are syntactic markers that define column and row boundaries, any data payload that contains those characters must follow exact escaping conventions to prevent file corruption.

Delimiter Enclosure

If a cell value contains the chosen delimiter character (e.g., Acme, Inc.), the entire field must be enclosed in double quotes: "Acme, Inc.".

Quote Doubling

If a cell contains double quotation marks (e.g., He said "Hello"), each internal quote must be doubled: "He said ""Hello""".

Multiline Preservation

Embedded newlines (\n or \r\n) inside text fields are enclosed in quotes, allowing parsers to treat the block as a single cell rather than a new record.

DelimiterFormat CodePrimary Use CaseRegional & Technical Considerations
Comma (,)text/csvStandard relational data, US/UK spreadsheets, Python pandasStandard default. Clashes with European decimal notation.
Semicolon (;)text/csvEuropean localized Excel, DACH & Latin American financePrevents numeric values using decimal commas (12,50) from splitting.
Tab (\t)text/tab-separated-valuesTSV archives, clipboard pasting into Excel & Google SheetsRarely occurs in free text; ideal for copy-paste operations without escaping.
Pipe (|)text/plainData warehousing, mainframe exports, Unix pipeline processingHigh collision resistance in text containing both commas and semicolons.

Reverse Parsing: CSV to JSON Type Coercion

When operating in CSV to JSON mode, the parser converts flat text rows into structured JavaScript objects. Because CSV does not encode data types, the parser applies deterministic heuristic type inference across each cell:

Boolean Resolution

Strings matching "true" or "false" evaluate to boolean true and false primitives.

Numeric Resolution

Integers and floating-point patterns (e.g., 42, -12.8) cast to native JavaScript numbers.

Null Resolution

Literal "null" strings cast to explicit null values, distinguishing intentional absence from empty strings.

String Literal Default

Non-numeric, non-boolean text, and quoted empty cells are preserved as clean string literals.

Frequently Asked Questions

How do you convert nested JSON objects and arrays into flat CSV columns?

Because CSV is strictly a two-dimensional grid, nested properties are flattened using recursive dot-notation keys (such as user.address.city). For arrays, scalar values (strings, numbers) are concatenated into delimiter-separated values within a single cell, whereas arrays containing complex objects are serialized into compact JSON strings to prevent dimensional collision with the parent table structure.

Why do CSV files sometimes open with all data packed into a single column in Excel?

This typically occurs due to a delimiter mismatch between the CSV file and the operating system's regional settings. While North American and UK versions of Excel expect comma delimiters (,), European and Latin American systems expect semicolons (;) because the comma is reserved as the decimal separator. Selecting the semicolon delimiter or copying directly as a formatted table ensures columns split properly in all localized spreadsheet software.

How are commas, double quotes, and line breaks inside JSON values escaped in CSV?

Under RFC 4180, whenever a value contains a delimiter character, newline (\n or \r\n), or double quote, the entire field is wrapped in double quotation marks. Any literal double quotes within the value are escaped by doubling them (""). This prevents field boundaries from breaking and ensures that parsers and relational database loaders (like PostgreSQL COPY) ingest records accurately.

How does the converter handle inconsistent or missing keys across JSON objects?

Real-world API payloads often contain polymorphic objects where certain records omit optional attributes. The converter scans every object in the input array to construct a complete union of unique keys as the header row. For objects missing a specific property, an empty field is emitted, guaranteeing that all rows maintain an identical column count and column alignment.

How does reverse CSV to JSON conversion restore data types from plain text?

CSV files store all data as untyped plain text strings. During reverse conversion, lexical type detection evaluates each token: "true" and "false" are cast to native booleans, "null" resolves to null, and valid numeric strings are parsed into integers or IEEE 754 floating-point numbers. Non-numeric text and explicitly quoted empty fields remain as string literals.