JSON to CSV

Advertisement

Paste JSON data or upload a .json file and convert it to CSV format for spreadsheet applications.

Advertisement

About This Tool

JSON (JavaScript Object Notation) was introduced by Douglas Crockford in the early 2000s as a lightweight alternative to XML for data interchange. Formally specified in RFC 8259 (https://datatracker.ietf.org/doc/html/rfc8259) and standardized as ECMA-404, JSON quickly became the dominant format for web APIs and configuration files due to its simplicity and native support in JavaScript. CSV (Comma-Separated Values) predates JSON by decades, with origins tracing back to early mainframe computing in the 1970s. Formalized in RFC 4180 (https://datatracker.ietf.org/doc/html/rfc4180), CSV remains the universal tabular data format supported by virtually every spreadsheet application, database tool, and data analysis platform. Converting JSON to CSV bridges the gap between modern web data and traditional spreadsheet workflows. This is essential when exporting API responses for business reporting, preparing datasets for analysis in tools like Excel or Google Sheets, or sharing structured data with non-technical stakeholders who prefer tabular views. This converter handles the fundamental challenge of mapping hierarchical JSON structures to flat CSV rows. Arrays of objects are naturally suited to tabular representation, where each object becomes a row and each key becomes a column header. Nested objects are flattened using dot notation, preserving the data hierarchy in column names. All processing is performed entirely in your browser using the native JSON.parse() method. No data is transmitted to any server, ensuring complete privacy for sensitive datasets. The output conforms to RFC 4180 standards and is compatible with Excel, Google Sheets, LibreOffice Calc, and any other CSV-compatible application.

Sources: JSON.org · RFC Editor

How to Use

  1. Paste JSON data into the input field or upload a .json file.
  2. Adjust options like output delimiter, flatten mode, and Excel compatibility.
  3. Click Convert to generate CSV, then copy or download the result.

Understanding JSON and CSV Data Formats

JSON and CSV represent two fundamentally different approaches to structuring data. JSON is a hierarchical format that supports nested objects, arrays, and multiple data types including strings, numbers, booleans, and null values. Its tree-like structure makes it ideal for representing complex relationships between data entities, which is why it dominates modern web APIs and configuration files. CSV, by contrast, is a flat tabular format where data is organized into rows and columns. Each row represents a record and each column represents a field. This simplicity is its greatest strength: CSV files can be opened in any text editor, imported into any spreadsheet application, and processed by virtually every programming language and data tool. The conversion from JSON to CSV involves a fundamental transformation from hierarchical to tabular structure. This process, known as denormalization or flattening, requires decisions about how to handle nested objects, arrays, and missing values. Dot notation flattening (e.g., address.city) is the most common approach because it preserves the path information while producing valid column headers. Understanding when to use each format is key to effective data management. JSON excels at data interchange between systems, API responses, and configuration. CSV is preferred for data analysis, reporting, bulk imports into databases, and sharing data with non-technical users who work primarily with spreadsheet applications.

How to Use

  1. Paste JSON data into the input field or upload a .json file.
  2. Adjust options like output delimiter, flatten mode, and Excel compatibility.
  3. Click Convert to generate CSV, then copy or download the result.

Methodology

The conversion process begins by parsing the input using the browser's native JSON.parse() method, which validates the JSON syntax and produces a JavaScript object or array. The parser then performs a complete scan of all objects in the array to extract every unique key, building a comprehensive set of column headers. For nested objects, the flattening algorithm recursively traverses each level, concatenating parent and child keys with dot notation (e.g., user.address.city). This preserves the structural relationship while producing flat column names suitable for CSV. Value escaping follows the RFC 4180 standard precisely. Any field containing a comma, double quote, or newline character is enclosed in double quotes. Double quotes within values are escaped by doubling them. Arrays encountered as values are serialized to comma-separated strings. Null and undefined values produce empty fields, ensuring the output maintains consistent column alignment across all rows.

Sources: JSON.org · RFC Editor

Understanding Your Results

The CSV output begins with a header row containing column names derived from all unique JSON keys across the entire dataset. Each subsequent row maps to one object from the JSON array, with values placed in the column matching their key name. When objects have different sets of keys, the converter creates a superset of all columns. Missing values in any given object appear as empty cells in the corresponding row. This ensures data integrity while accommodating heterogeneous JSON structures. Nested objects are represented with flattened key names using dot notation (e.g., address.city, user.profile.name). This makes the hierarchical relationship visible in the column headers while keeping the data in a standard flat tabular format. When importing the CSV into a spreadsheet, these dot-notated column names can help you reconstruct the original nesting structure if needed.

Practical Examples

A simple array of objects converts directly to rows and columns. For instance, [{"name": "John Doe", "email": "[email protected]", "age": 30}, {"name": "Jane Smith", "email": "[email protected]", "age": 25}] produces a CSV with headers name, email, age, followed by one row per object. Nested objects are flattened with dot notation. For example, [{"user": {"name": "Alice", "address": {"city": "Berlin"}}, "role": "admin"}] produces columns user.name, user.address.city, and role. This approach handles API responses that commonly include nested profile, address, or metadata objects while maintaining a readable tabular structure.

Tips & Best Practices

For the cleanest CSV output, ensure your JSON objects have consistent keys across all items in the array. When objects have mismatched keys, empty cells are inserted for missing values, which may require cleanup in your spreadsheet. If your JSON contains deeply nested structures, consider pre-processing to limit nesting depth. Column names like user.profile.address.street.line1 can become unwieldy in spreadsheets. Flattening to two or three levels usually provides the best balance between detail and readability. When working with large datasets, paste your JSON directly rather than typing it. The converter processes data entirely in memory, so very large files (over 50 MB) may be slow on older devices. For such cases, consider splitting the data into smaller batches.

All calculations are performed locally in your browser. No data is sent to any server.

Embed This Tool

Get embed code

Was this tool helpful?
Want to tell us more?
0/500
Want us to follow up?
Thanks for your feedback!

Frequently Asked Questions

What JSON format does this converter accept?
The converter works best with JSON arrays of objects, where each object has the same keys. For example: [{name: John, age: 30}, {name: Jane, age: 25}]. Single objects and nested structures are also supported - nested keys are flattened using dot notation.
How are nested JSON objects handled?
Nested objects are flattened using dot notation. For example, {user: {name: John, address: {city: NYC}}} becomes columns user.name and user.address.city. Arrays within objects are converted to comma-separated strings.
Can I use the output in Excel?
Yes! The CSV output is compatible with Excel, Google Sheets, LibreOffice Calc, and any other spreadsheet application. Download the .csv file and open it directly in your preferred application. The first row contains headers derived from the JSON keys.
How are arrays inside JSON objects handled?
When a JSON property contains an array, the tool flattens it into the CSV. Simple arrays of primitives (strings, numbers) are joined into a single cell, typically separated by a delimiter like a semicolon. Nested arrays of objects are expanded into additional columns or rows depending on the flattening strategy. For complex nested structures with mixed arrays and objects, consider pre-processing the JSON to extract the specific data you need before converting to the inherently flat CSV format.
Will the CSV preserve data types like numbers and booleans?
CSV is a plain-text format with no data type information — every value is stored as text. Numbers like 42 and booleans like true are written as their string representation. When you open the resulting CSV in Excel or Google Sheets, the spreadsheet application will attempt to auto-detect types, which usually works well for numbers and dates. However, values like ZIP codes with leading zeros (e.g., '02101') may be incorrectly interpreted as numbers. To preserve leading zeros, wrap such values in quotes or format the column as text in your spreadsheet.
Is my data sent to a server during conversion?
No. All JSON-to-CSV conversion happens entirely in your browser using JavaScript. Your data never leaves your device. This makes the tool safe for converting sensitive or proprietary data, including API responses, database exports, and configuration files. You can verify this by disconnecting from the internet and using the tool — it will continue to work normally because no server communication is involved.
Can I upload a JSON file?
Yes! Click the upload button next to the input label or drag and drop a .json file directly onto the input area. The file is read locally in your browser — no data is uploaded to any server. Files up to 50 MB are supported.
What does the BOM option do?
BOM stands for Byte Order Mark — a hidden character () placed at the beginning of the file. When enabled, it signals to Excel and other spreadsheet applications that the file uses UTF-8 encoding. This prevents garbled characters when opening CSV files that contain accented letters, Asian characters, or other non-ASCII text. Most modern applications handle UTF-8 automatically, but enabling BOM ensures maximum compatibility with older versions of Excel.