All free tools

Free tool · technology

JSON to CSV

Flatten an array of JSON objects into a CSV table.

Your input

Result

Your result appears here as you type.

Runs in your browser · Nothing is uploaded

Embed this on your site

Free to embed. The attribution link stays with the widget, and the calculator keeps working exactly as it does here.

<iframe src="https://thedigitalstash.net/embed/json-to-csv" title="The Digital Stash calculator" width="100%" height="720" style="border:0;max-width:100%" loading="lazy"></iframe>

Understanding the JSON to CSV conversion process

The JSON to CSV tool is designed to translate data structures from the JavaScript Object Notation format into Comma Separated Values. JSON is a hierarchical, text based format often used for web application data, while CSV is a flat, tabular format suited for spreadsheets and database imports. This tool performs a flattening operation, which converts nested JSON objects into a two dimensional grid of rows and columns.

The method of conversion

The tool processes an array of JSON objects by identifying the keys present in each object. These keys become the column headers in the resulting CSV file. For each object in the array, the tool maps the associated values to the corresponding column.

If the JSON data contains nested objects or arrays, the tool flattens these by using a dot notation. For example, a nested address field containing a city value would be represented as address.city. This approach ensures that no data is lost during the transition from a hierarchical tree structure to a flat table.

A worked example

Consider a scenario where an application returns a list of sensor readings in JSON format.

Input JSON data:

[
  {
    "sensor_id": 101,
    "location": "North",
    "reading": {
      "temperature": 22.5,
      "humidity": 45
    }
  },
  {
    "sensor_id": 102,
    "location": "South",
    "reading": {
      "temperature": 21.8,
      "humidity": 48
    }
  }
]

When this is passed through the converter, the tool flattens the reading object. The output CSV format will look like this:

| sensor_id | location | reading.temperature | reading.humidity | | :--- | :--- | :--- | :--- | | 101 | North | 22.5 | 45 | | 102 | South | 21.8 | 48 |

In this example, the tool has promoted the nested temperature and humidity values to top level columns, prefixed with the parent key name.

Interpreting the results

The resulting CSV file provides a structured view of the data. Each row represents a distinct object from the original JSON array, and each column represents a specific attribute. Empty cells will appear if some objects in the original JSON array lack certain keys. This format allows you to open the data directly in spreadsheet software like Microsoft Excel, LibreOffice Calc, or Google Sheets for further analysis, filtering, or sorting.

Assumptions and limits

The tool operates under several technical assumptions:

  1. Consistency: The tool assumes the input is a valid JSON array. If the syntax is malformed, the conversion will fail.
  2. Uniformity: The tool assumes that the structure of the objects within the array is relatively consistent. If objects differ significantly in structure, the CSV may contain a large number of empty cells.
  3. Size: The tool is intended for standard data extracts. Extremely large JSON files, particularly those exceeding several megabytes, may cause performance issues or browser crashes due to the memory constraints of the client side environment where this tool runs.
  4. Character Encoding: The tool assumes UTF-8 encoding. Characters outside of this standard may not render correctly in the CSV file.
  5. Recursion Depth: Deeply nested JSON structures may result in long, complex column headers when flattened. There is a practical limit to how much information can be clearly represented in a column header.

Who this tool is not for

This tool is not intended for users who require complex data transformation logic, such as performing arithmetic calculations during conversion, merging multiple disparate JSON files into a single master set, or sanitising sensitive data before export. It is also not suitable for automated server side pipelines that need to process thousands of files per hour.

Furthermore, this tool is not appropriate for those handling highly sensitive or confidential data. Because the conversion process occurs within the user's web browser for privacy, it is not an enterprise grade solution designed for audit logging, data governance, or high security compliance requirements. Those requiring advanced data manipulation, or integration with database systems and APIs, should consider using dedicated scripting languages like Python or R, which offer granular control over data parsing and validation.

More tools like this