# Convert JSON to CSV

Paste a JSON array of objects and get CSV back. The header row is the union of every key across your objects, so an object missing a field produces an empty cell rather than a shifted row.

*Last updated: 2026-07-14 · Source: <https://pastesheet.com/tools/json-to-csv>*

## Using this without the browser

This page hosts an interactive tool: at <https://pastesheet.com/tools/json-to-csv> you paste a Google Sheet URL and it returns the result in the page. There is nothing to install and no account required.

If you are an agent or a script and need this programmatically instead, connect the sheet once as a PasteSheet endpoint and read it over HTTP — the endpoint returns the same rows as JSON, stays in sync with the sheet, and needs no Google credentials:

```bash
curl 'https://pastesheet.com/api/your-endpoint-id?limit=10'
```

The same endpoint is also a read-only MCP server at `https://pastesheet.com/mcp/sheets/your-endpoint-id`, exposing `list_tabs`, `get_schema` and `query_rows`. See <https://pastesheet.com/guides/google-sheets-mcp.md>.

## How it handles ragged objects

CSV is rectangular and JSON is not, which is the whole difficulty. The header row is built from the **union of every key across every object**, in first-seen order. An object that is missing one of those keys gets an empty cell for it, rather than having its remaining values shift left into the wrong columns.

Values are escaped per [RFC 4180](https://www.rfc-editor.org/rfc/rfc4180): anything containing a comma, a double quote or a newline is quoted, and literal quotes are doubled. Nested objects and arrays are serialised back to compact JSON inside their cell, because a CSV cell cannot hold structure.

## What the output looks like

```bash
name,role
"Lovelace, Ada",Engineer
"Grace ""Amazing Grace"" Hopper",Admiral
```

## Going the other way

Need the reverse? [Convert CSV to JSON](https://pastesheet.com/tools/csv-to-json). And if the JSON is coming out of a spreadsheet in the first place, a [PasteSheet endpoint](https://pastesheet.com) serves it as JSON at a live URL, so you can skip the export-and-convert round trip entirely.

## Frequently asked questions

### What if my objects have different keys?

The header row is the union of every key across every object, in first-seen order, and an object missing a key gets an empty cell for it. That keeps the output rectangular — the alternative, using only the first object's keys, silently drops data that appears later in the array.

### What happens to nested objects and arrays?

They are serialised back to compact JSON inside the cell. A CSV cell holds a string and nothing else, so there is no lossless way to flatten arbitrary structure into one — keeping it as JSON at least means nothing is thrown away.

### Does it accept a single object rather than an array?

Yes. A single JSON object is treated as a one-row array, so you get a header row and one data row. Anything that is not an object or an array of objects cannot become a table, and the tool will tell you so rather than guessing.

## Sources

- [RFC 8259 — The JavaScript Object Notation (JSON) Data Interchange Format](https://www.rfc-editor.org/rfc/rfc8259) — IETF
- [RFC 4180 — Common Format and MIME Type for CSV Files](https://www.rfc-editor.org/rfc/rfc4180) — IETF

## Related tools

- [Free CSV to JSON Converter Online](https://pastesheet.com/tools/csv-to-json) — Paste CSV and get formatted JSON back — one object per row, keyed by the header row. Quoted fields, embedded commas and newlines all handled. Free, no signup.
- [Free JSON Formatter and Validator](https://pastesheet.com/tools/json-formatter) — Paste JSON to pretty-print and validate it. Invalid JSON gets the exact error and where it happened, so you can find the missing comma. Free, no signup.
- [Google Sheets to CSV Converter (Free)](https://pastesheet.com/tools/google-sheets-to-csv) — Paste a Google Sheet URL and download it as clean, RFC 4180 CSV — no Google account, no sign-in, and no export menu. Works on any sheet shared with a link.

---

[PasteSheet](https://pastesheet.com) turns any Google Sheet into a live REST API and MCP server for AI agents — no backend, no code. Canonical HTML version of this page: <https://pastesheet.com/tools/json-to-csv>
