FormatForge

JSON to CSV Converter

Convert JSON arrays to CSV format instantly. Free, secure, and works entirely in your browser.

JSON
CSV

Drop a file here or click to upload

Supports .json files

Understanding JSON and CSV

JSON (JavaScript Object Notation) is a lightweight data-interchange format that represents structured data as nested key-value pairs, arrays, and primitive values. It is the lingua franca of web APIs and is natively understood by JavaScript, Python, Ruby, and dozens of other languages. JSON excels at describing hierarchical relationships — a single document can contain objects within objects, arrays of mixed types, and deeply nested trees of data. To learn more about JSON syntax, valid data types, and best practices, visit our JSON guide.

CSV (Comma-Separated Values) is one of the oldest and simplest tabular data formats. Each line represents a row, and values within a row are separated by a delimiter — most commonly a comma. CSV files can be opened by virtually every spreadsheet application (Excel, Google Sheets, LibreOffice Calc) and imported by every database engine and data-analysis library. Its flat, two-dimensional structure makes it ideal for datasets where every record shares the same set of fields. For a deeper dive into CSV nuances such as quoting rules, escape characters, and RFC 4180 compliance, see our CSV guide.

The fundamental challenge of converting JSON to CSV is bridging the gap between a hierarchical format and a flat table. This converter handles that gap automatically by flattening nested structures and mapping each unique key path to a dedicated column.

Why Convert JSON to CSV?

Despite JSON's dominance in web development, there are many scenarios where CSV is the better choice. Here are the most common real-world reasons to convert JSON to CSV:

  • Importing API data into Excel or Google Sheets. Most REST APIs return JSON, but business stakeholders prefer spreadsheets for filtering, sorting, and creating pivot tables. Converting JSON to CSV bridges that gap instantly.
  • Data analysis with pandas or R. While pandas can read JSON directly, CSV loading is significantly faster for large datasets because the parser does not need to handle nesting. Analysts working with flat datasets often prefer CSV as the input format.
  • Migrating from NoSQL to a relational database. If you are moving documents from MongoDB or Firebase to PostgreSQL or MySQL, you need to flatten each document into rows and columns. JSON-to-CSV conversion is the first step in that pipeline.
  • Generating reports from JSON APIs. Automated reporting systems often consume CSV because it integrates seamlessly with mail-merge tools, BI dashboards (Tableau, Power BI), and legacy enterprise systems.
  • Sharing data with non-technical collaborators. Not everyone is comfortable reading raw JSON. A CSV file can be opened with a double-click in any spreadsheet application, making it far more accessible for project managers, accountants, and clients.

How the Conversion Works

The converter follows a deterministic multi-step process to turn your JSON into well-formed CSV:

  1. Parse and validate the input to ensure it is a valid JSON array of objects.
  2. Collect all unique key paths across every object, including nested paths expressed in dot notation (e.g., address.city).
  3. Flatten nested objects so that every leaf value maps to a single column. An object like {"user":{"name":"Jo"}} becomes the column user.name.
  4. Build the header row from the collected key paths in stable order.
  5. Emit each object as a CSV row, quoting any value that contains the delimiter, a newline, or a double quote.

The table below shows how common JSON constructs map to CSV columns:

JSON ConstructCSV Representation
"name": "Alice"Column name with value Alice
"address": {"city": "NYC"}Column address.city with value NYC
"tags": ["a", "b"]Column tags with value a,b (joined)
"active": trueColumn active with value true
"score": nullColumn score with empty cell

Before and After Example

Below is a practical example showing a JSON array of three products with nested category objects, and the resulting CSV output with flattened headers.

Input JSON

[
  {
    "id": 1,
    "name": "Wireless Mouse",
    "price": 29.99,
    "category": {
      "id": 10,
      "name": "Accessories"
    },
    "inStock": true
  },
  {
    "id": 2,
    "name": "Mechanical Keyboard",
    "price": 89.50,
    "category": {
      "id": 11,
      "name": "Peripherals"
    },
    "inStock": true
  },
  {
    "id": 3,
    "name": "USB-C Hub",
    "price": 45.00,
    "category": {
      "id": 10,
      "name": "Accessories"
    },
    "inStock": false
  }
]

Output CSV

id,name,price,category.id,category.name,inStock
1,Wireless Mouse,29.99,10,Accessories,true
2,Mechanical Keyboard,89.50,11,Peripherals,true
3,USB-C Hub,45.00,10,Accessories,false

Notice how the nested category object was flattened into two separate columns: category.id and category.name. Every leaf value in the original JSON maps to exactly one cell in the output CSV.

Tips and Best Practices

Flatten deeply nested objects first

If your JSON has more than two or three levels of nesting, consider pre-processing it to flatten the structure before conversion. Extremely deep nesting produces long dot-notation column names like order.items.0.product.category.name that can be hard to work with in spreadsheets.

Handle arrays within objects carefully

Arrays of primitive values are joined into a single cell. However, arrays of objects are more complex — each element gets flattened into indexed columns. If your data has variable-length arrays, expect the CSV to have many sparse columns. Consider extracting sub-arrays into separate CSV files instead.

Choose the right CSV delimiter

Commas are standard, but if your data contains commas in text fields (descriptions, addresses), consider using semicolons or tabs as delimiters. In European locales where commas serve as decimal separators, semicolons are the preferred CSV delimiter.

Enable BOM for Excel compatibility

When your data includes non-ASCII characters (accented letters, CJK characters, currency symbols), enable the BOM (Byte Order Mark) option before downloading. Without the BOM, Excel may misinterpret the file encoding and display garbled characters.

Validate your JSON before converting

Common JSON errors like trailing commas, unquoted keys, or single-quoted strings will cause the conversion to fail. Use FormatForge's built-in error highlighting to identify the exact line and column where the issue occurs.

Use JSONPath to filter before converting

If your JSON contains a large payload but you only need a subset, use the JSONPath filter feature to extract the relevant array before conversion. For example, $.data.results[*] can pull just the results array from an API response wrapper.

Related Tools

Explore other converters and resources that complement JSON-to-CSV conversion:

How to Convert JSON to CSV

  1. Paste your JSON data in the input area, or upload a JSON file
  2. Click the "Convert" button
  3. View the converted CSV output instantly
  4. Copy the result or download it as a file

Features

  • 100% client-side - your data never leaves your browser
  • No login or registration required
  • Instant conversion with real-time preview
  • Supports file upload and drag-and-drop
  • Download converted files directly
  • Works on mobile and desktop

Frequently Asked Questions

How does JSON to CSV conversion work?

The converter takes your JSON array of objects and transforms each object into a row, with the object keys becoming column headers. Nested objects are flattened using dot notation (e.g., user.name).

What JSON format is supported?

The converter accepts JSON arrays of objects. Each object in the array becomes a row in the CSV. For example: [{"name": "John", "age": 30}, {"name": "Jane", "age": 25}]

How are nested JSON objects handled?

Nested objects are automatically flattened. For example, {"user": {"name": "John"}} becomes a column named "user.name" with the value "John".

Is my data secure?

Yes, all conversion happens directly in your browser. Your data is never sent to any server or stored anywhere.

Can I choose a different CSV delimiter?

Yes. FormatForge supports comma, semicolon, and tab delimiters. You can select the delimiter in the conversion options before running the conversion. Semicolons are common in European locales where the comma is used as a decimal separator.

What happens to arrays inside my JSON objects?

Arrays that contain primitive values (strings, numbers) are joined into a single cell value. Arrays of objects are flattened so that each nested key gets its own column with dot-notation headers, ensuring no data is lost in the conversion.

How do I open the resulting CSV in Excel without encoding issues?

Enable the BOM (Byte Order Mark) option before downloading. The BOM tells Excel to interpret the file as UTF-8, which ensures special characters like accented letters, currency symbols, and CJK characters display correctly.

Is there a file size limit for JSON to CSV conversion?

The converter works entirely in your browser, so performance depends on your device. Files up to 5 MB typically convert instantly. For very large datasets, consider splitting the JSON array into smaller chunks before converting.