JSON to CSV Converter

How to Convert JSON to CSV (and Back)

📅 April 2026⏱ 7 min read✍️ ToolsBox

JSON and CSV are the two most common formats for transferring and storing structured data. JSON is the native language of APIs and web applications; CSV is the native language of spreadsheets and data analysis tools. At some point, almost every developer or data professional needs to move data between the two — and understanding how the conversion works prevents a lot of headaches.

JSON vs CSV: What Is the Difference?

JSON (JavaScript Object Notation) is a hierarchical text format that can represent complex, nested data structures. It supports strings, numbers, booleans, nulls, objects, and arrays — making it ideal for API responses and configuration files.

CSV (Comma-Separated Values) is a flat text format where each row represents a record and each column represents a field. It is simple, human-readable, and universally supported by spreadsheet applications like Excel and Google Sheets.

Here is the same data in both formats:

JSON:

[
  {"name": "Alice", "age": 30, "city": "London"},
  {"name": "Bob", "age": 25, "city": "Paris"}
]

CSV:

name,age,city
Alice,30,London
Bob,25,Paris

The CSV version is simpler and immediately importable into Excel. The JSON version can represent more complex structures.

How JSON to CSV Conversion Works

Converting a JSON array to CSV is straightforward when the data is flat (no nested objects or arrays):

  1. Extract all unique keys from the first object (or all objects) to form the CSV header row.
  2. For each object in the array, write one CSV row with the values in the same key order as the header.
  3. Wrap any values containing commas or newlines in double quotes.
  4. Escape any double quotes inside values by doubling them (" becomes "").

The challenge comes with nested data. Consider this JSON:

{"name": "Alice", "address": {"city": "London", "postcode": "EC1"}}

CSV cannot represent the address object natively. Common solutions are:

  • Dot notation flattening: address.city and address.postcode become separate column headers.
  • JSON string serialisation: The entire address object is stored as a JSON string in a single CSV column.
  • Manual selection: You choose which nested fields to extract into columns.

Converting JSON to CSV Online

Our JSON to CSV Converter handles both flat and nested JSON. Here is how to use it:

  1. Open the JSON to CSV Converter on ToolsBox.
  2. Paste your JSON array into the input area. The JSON must be an array of objects — [{...}, {...}].
  3. Click Convert. The tool extracts all keys as headers and maps each object to a row.
  4. Copy the CSV output or download it as a .csv file.
  5. Open in Excel, Google Sheets, or any data analysis tool.

The tool also supports converting CSV back to JSON — useful when you receive a CSV export from a database or analytics platform and need to process it in JavaScript. You can also use the JSON Formatter to validate and prettify your JSON before converting.

Converting CSV Back to JSON

Converting CSV to JSON reverses the process: each header becomes a key, and each row becomes an object in the output array. Our converter handles this automatically when you switch to CSV-to-JSON mode.

One important consideration: CSV stores everything as strings. If your original JSON had numeric values, they will come back as strings unless the converter performs type inference. Our tool attempts to convert numeric strings back to numbers and "true"/"false" values back to booleans.

JSON to CSV in Code

If you need to automate the conversion in your application, here are the most common libraries by language:

  • JavaScript/Node.js: json2csv or papaparse for both directions. papaparse is especially good for large CSV files with streaming support.
  • Python: The built-in csv module handles CSV well, or use pandas for complex transformations: df = pd.DataFrame(json_data); df.to_csv('output.csv', index=False).
  • PHP: Use fputcsv() in a loop to write rows from a decoded JSON array.
  • Ruby: The CSV standard library combined with JSON.parse covers most use cases.

Convert JSON to CSV — free

Paste your JSON array and get a clean CSV instantly. No signup, no limits.
Open JSON to CSV Converter →

Frequently Asked Questions

When should I use JSON vs CSV?

Use JSON when data has nested structures, multiple data types, or needs to be consumed by an API or web application. Use CSV when data is flat (rows and columns), needs to be opened in Excel or Google Sheets, or shared with non-technical users.

Can nested JSON be converted to CSV?

Not directly — CSV is a flat format that cannot represent nesting. You need to flatten the JSON first, choosing how to handle nested objects (e.g. dot notation for keys like 'address.city') and arrays (either spread as separate columns or serialise as a string).

Does JSON to CSV conversion lose any data?

It can. CSV cannot represent nested objects, arrays, null values (it uses empty strings), or the distinction between numbers and strings. For a lossless round-trip, JSON is the better format. CSV conversion is best when you need the data in a spreadsheet.

How do I open a CSV file in Excel?

Double-click the .csv file to open it directly in Excel, or use File → Open. If commas are not recognised as delimiters, use the Data → Text to Columns wizard. For files with non-ASCII characters, use the import wizard and select UTF-8 encoding to avoid garbled text.

Back to Blog  |  Related tool: JSON to CSV Converter