2026topopentools

JSON ↔ CSV Converter

Convert an array of JSON objects into clean CSV, or parse CSV — including quoted fields with commas and line breaks — back into pretty-printed JSON, all in your browser.

Everything runs in your browser — your data is never uploaded to a server.

Understanding the JSON ↔ CSV Converter

The JSON ↔ CSV Converter turns an array of JSON objects into spreadsheet-ready CSV, and parses CSV (even with quoted fields containing commas or line breaks) back into pretty-printed JSON. It is built for developers, analysts, and anyone moving data between APIs, databases, and spreadsheets like Excel or Google Sheets. A single object is automatically wrapped in an array, and the CSV header is the union of every key seen. Everything runs locally in your browser using plain JavaScript — your data is never uploaded to a server, making it safe for sensitive or proprietary datasets.

How it works

For JSON → CSV, the tool runs JSON.parse, wraps a lone object in an array, then walks all rows to collect a first-seen-ordered union of keys as the header. Each value becomes a cell: strings stay as text, numbers and booleans are stringified, null becomes empty, and nested objects or arrays are JSON-stringified. Any cell containing a comma, double quote, or newline is wrapped in double quotes with internal quotes doubled (RFC 4180). For CSV → JSON, a hand-written state-machine parser reads the text character by character, tracking quoted regions so commas and newlines inside quotes stay intact and "" decodes to a single quote. The first row becomes the keys; each later row becomes one object.

Worked example

Paste [{"name":"Ann","age":30},{"name":"Bob","city":"Paris"}] in JSON → CSV mode and click Convert. The header is the union of keys — name,age,city — and the output is three lines: the header, then Ann,30, (empty city) and Bob,,Paris (empty age). Switch to CSV → JSON, paste name,age then Ann,30, and you get [{"name":"Ann","age":"30"}] as 2-space pretty JSON. A field like "Smith, Jr." stays one cell because it is wrapped in quotes.

Tips & common mistakes

  • JSON → CSV expects an array of objects; a single object is auto-wrapped, but plain arrays of strings or numbers are rejected with a clear message.
  • Columns are the union of all keys, so objects can have different fields — missing keys simply become empty cells in that row.
  • Nested objects and arrays are stringified into one cell as compact JSON, not exploded into extra columns — flatten your data first if you need separate columns.
  • CSV → JSON reads every value as a string, including numbers like "30"; cast or parse them afterward if you need real numeric types.
  • Quoted fields are fully supported: commas, line breaks, and doubled quotes ("") inside double-quoted fields are decoded per RFC 4180.
  • The first CSV row is always treated as the header — remove any title or blank lines above it before converting.

Related tools

Frequently Asked Questions

Does it handle nested JSON objects and arrays?

CSV is a flat format, so nested objects and arrays are stringified into a single cell as compact JSON. The structure is preserved as text, but it is not split into extra columns.

Are quoted CSV fields supported?

Yes. The parser follows RFC 4180: fields wrapped in double quotes may contain commas, line breaks, and escaped double quotes (written as two quotes, ""), and they are decoded correctly.

Is my data uploaded anywhere?

No. All parsing and conversion happen locally in your browser using JavaScript. Your JSON and CSV never leave your device and nothing is sent to a server.