How to Use the JSON to CSV Converter
Paste a JSON array of objects into the input textarea. Each object in the array represents a row, and the object keys become the CSV column headers. Select a delimiter format from the dropdown menu: comma is the default and most common, but tab, semicolon, and pipe are available for different use cases. Click "Convert to CSV" to generate the output. The status bar shows the number of data rows, columns, and detected headers. The table preview below the output textarea displays the data in a formatted table for visual verification. Use the copy button to grab the CSV text or the download button to save it as a .csv file.
The converter automatically handles heterogeneous JSON objects by computing the union of all keys across every object in the array. If an object is missing a key that appears in other objects, the corresponding CSV cell is left empty. This ensures a complete rectangular table regardless of how uniform the source data is. Values containing the delimiter character, double quotes, or newlines are properly escaped according to the CSV standard (RFC 4180).
Understanding JSON to CSV Conversion
JSON (JavaScript Object Notation) and CSV (Comma-Separated Values) are two of the most widely used data interchange formats, but they represent data in fundamentally different ways. JSON is hierarchical and supports nested objects, arrays, and typed values (strings, numbers, booleans, null). CSV is flat and tabular, with every value represented as text. Converting from JSON to CSV requires flattening the data structure: each object becomes a row, and each key becomes a column. This works naturally when the JSON is an array of flat objects with consistent keys, which is the most common format for API responses, database exports, and data feeds.
Header Extraction from Object Keys
The first step in JSON to CSV conversion is determining the column headers. The converter inspects every object in the array and collects all unique keys, preserving their first-encountered order. This union approach ensures that no data is lost even when objects have different key sets. For example, if the first object has keys "name" and "email" while the second has "name" and "phone", the resulting CSV has three columns: name, email, and phone. Objects missing a key get an empty cell for that column. This is more robust than using only the first object's keys, which is a common shortcut that silently drops data from objects with extra fields.
Type Conversion and Special Values
JSON supports typed values (numbers, booleans, null), but CSV treats everything as text. The converter represents each value as its string form: numbers keep their numeric format, booleans become "true" or "false", and null values become empty strings. Nested objects and arrays within a JSON object pose a particular challenge because CSV cells cannot natively contain structured data. This converter renders nested values as their JSON string representation, which is the most lossless approach. If your data contains deep nesting, consider flattening the JSON before conversion using a dedicated tool or a dot-notation key expansion.
CSV Escaping Rules
Proper CSV generation requires careful handling of special characters within field values. The escaping rules defined by RFC 4180 state that fields containing the delimiter character, double-quote characters, or line breaks must be enclosed in double quotes. Any double-quote character within a quoted field must be escaped by doubling it (replacing one " with ""). Fields that do not contain special characters may optionally be quoted. This converter applies quoting only when necessary, producing clean output that is compatible with all standards-compliant CSV parsers, including Microsoft Excel, Google Sheets, LibreOffice Calc, and command-line tools like csvkit and pandas.
Choosing the Right Delimiter
The delimiter choice depends on the target system and locale. Comma-separated values are the universal default and work everywhere. Tab-separated values (TSV) are preferred when field values frequently contain commas, such as addresses or descriptions, because tabs rarely appear in natural text. Semicolons are the standard in continental European locales where the comma serves as the decimal separator in numbers. Pipe-delimited files are common in financial services, healthcare (HL7 messages), and mainframe systems. When in doubt, use comma as it provides the broadest compatibility.
Frequently Asked Questions
How does JSON to CSV conversion work?
The converter extracts all unique keys from every object in the JSON array to form the CSV header. Each object becomes a data row, with values mapped to their corresponding columns. Missing keys produce empty cells.
What JSON structure is required?
The input must be a JSON array of objects, like [{"key":"value"}, ...]. Every element must be an object. The array cannot be empty. Nested values are stringified in the CSV output.
How are missing values handled?
The converter uses the union of all keys as headers. Objects missing a key get an empty CSV field for that column, producing a complete rectangular table from sparse data.
Which delimiter should I choose?
Comma is universal. Tab avoids ambiguity when values contain commas. Semicolons suit European locales. Pipe delimiters are common in financial and enterprise systems.
How are special characters handled?
Values containing the delimiter, double quotes, or newlines are automatically wrapped in double quotes per RFC 4180. Internal double quotes are escaped by doubling them.
Save your results & get weekly tips
Get calculator tips, formula guides, and financial insights delivered weekly. Join 10,000+ readers.
No spam. Unsubscribe anytime.