DevToolsmith

JSON to CSV Converter

Paste a JSON array, a single object or JSON Lines to get a CSV file for Excel, Google Sheets or a database import. Nested objects are flattened into columns and rows with different keys are merged.

Runs 100% in your browser — nothing is uploaded

JSON or JSON Lines
Tip: drop a file here368 chars · 368 bytes · 5 lines
CSV · 3 rows, 8 columns
215 chars · 215 bytes · 4 lines

How the conversion works

Each object in the array becomes one row. The header row is the union of all keys, in the order they first appear, so objects don’t need identical shapes. Nested objects are flattened into dot.separated columns, and arrays are kept as JSON in a single cell:

JSON
[
  { "id": 1, "name": "Ada", "address": { "city": "London" }, "tags": ["admin", "ops"] },
  { "id": 2, "name": "Grace", "email": "grace@example.com" }
]
CSV
id,name,address.city,tags,email
1,Ada,London,"[""admin"",""ops""]",
2,Grace,,,grace@example.com

Values are quoted only when needed, following RFC 4180: when they contain the delimiter, a double quote, a line break, or leading or trailing spaces. Quotes inside values are doubled (""). null becomes an empty cell. Lines end with CRLF, which every spreadsheet and CSV library understands.

Supported input

  • Array of objects, the usual output of REST APIs and database exports.
  • A single object, which becomes a one-row CSV.
  • JSON Lines / NDJSON: one JSON object per line, as written by many log tools and BigQuery exports.
  • Array of arrays: rows of values, with the first row used as the header.
  • Array of primitives, which becomes a single value column.

Converting JSON to CSV in code

jq

# Flat objects: use the first object's keys as the header
jq -r '(.[0] | keys_unsorted) as $k | $k, (.[] | [.[$k[]]]) | @csv' data.json > data.csv

Python (pandas)

import json
import pandas as pd

with open("data.json") as f:
    data = json.load(f)

# json_normalize flattens nested objects into "address.city" columns
pd.json_normalize(data).to_csv("data.csv", index=False)

Node.js

import { readFileSync, writeFileSync } from 'node:fs';
import Papa from 'papaparse';

const rows = JSON.parse(readFileSync('data.json', 'utf8'));
writeFileSync('data.csv', Papa.unparse(rows));

The jq version uses the first object’s keys only, so keys that appear later are dropped. The converter above checks every object.

Going the other way? Use CSV to JSON, or inspect the result in the CSV Viewer.

Frequently asked questions

How do I convert JSON to CSV?

Paste a JSON array of objects into the tool above. Each object becomes a row and each key becomes a column; the CSV updates as you type. Click Download to save it as a .csv file you can open in Excel, Google Sheets or Numbers.

How are nested objects handled?

With “Flatten nested objects” on, nested keys become dot-separated columns: {"address": {"city": "London"}} becomes an address.city column. Turn it off to keep each nested object as a JSON string in a single cell.

What happens when objects have different keys?

The CSV gets one column for every key that appears in any object, in the order keys are first seen. Rows that don’t have a key get an empty cell, so no data is lost.

How are arrays converted?

An array inside an object is written as JSON in one cell, e.g. ["admin","ops"], so it can be parsed back later. A top-level array of arrays is treated as rows, with the first array as the header.

Why do non-English characters look broken in Excel?

Excel on Windows assumes the system code page when you double-click a CSV file without a byte order mark. Instead, open Excel and use Data → From Text/CSV and choose UTF-8, or import the file in Google Sheets, which always reads UTF-8.

What is CSV formula injection?

Spreadsheets treat a cell starting with =, +, - or @ as a formula. If your JSON contains user-supplied text like =HYPERLINK(...), opening the CSV can run it. “Protect against formula injection” prefixes such text cells with an apostrophe so they are shown as text. Numbers are never changed.