Vai al contenuto
NeedToConvert

JSON in CSV

Trasforma risposte API ed esportazioni JSON in una tabella pronta per il foglio di calcolo, con i campi annidati appiattiti in colonne.

  • Gratis
  • Privato
  • Senza registrazione
Funziona sul tuo dispositivo. Nulla di ciò che inserisci viene caricato.

JSON is how APIs, NoSQL databases and logging tools hand you data, but the people who need to read it usually work in Excel, Google Sheets or a BI dashboard. Converting a JSON array to CSV gives every record a row and every field a column, so the data can be filtered, pivoted and charted.

Paste JSON or open a .json file, and the CSV appears beside it as you type. Nested objects are flattened into dotted column names, you choose which columns to keep, and you can download a file that Excel opens with accents and non-Latin scripts intact. The conversion runs in your browser, so tokens or personal data inside the payload stay on your computer.

From a tree to a table

A CSV file is flat: rows and columns, nothing inside anything else. JSON is a tree, where a customer can contain an address object that in turn contains a city. Turning one into the other means deciding how the branches are laid out as columns. The common answer, used here, is dot notation: a customer whose address object holds "city": "Berlin" gets a column named address.city with the value Berlin.

The tool first finds the records. A top-level array gives one row per item. An object whose only array property is non-empty, the typical API envelope such as {"data": [...]} or {"results": [...]}, is unwrapped and that list is converted, with a note naming the key that was used. Any other object becomes a single row, and an array of arrays is written as plain rows without a header line. Primitive values inside an array go into a column called value.

Where JSON to CSV saves time

Reporting on API data

Pull orders from a store's API or issues from GitHub, convert the response, and build a pivot table without writing a script.

Handing data to non-developers

Analysts, accountants and support teams rarely want raw JSON. A CSV with readable column names is something they can sort and filter on their own.

Loading into SQL and BI tools

PostgreSQL's COPY, MySQL's LOAD DATA, BigQuery, Power BI and Tableau all import CSV natively. Flattening first avoids JSON functions inside the database and makes each field its own column.

Flattening rules and output format

Flatten nested objects is on by default. Each nested key is joined to its parent with a dot, to a depth of 100 levels; anything deeper is kept as JSON text in one cell. Switch flattening off and every nested object or array is written as compact JSON text inside its cell.

Arrays have two modes. JSON text writes ["admin","beta"] into a single tags cell and keeps the column count stable. Column per item spreads the list into tags.0, tags.1 and so on, which suits short, fixed-length lists such as coordinates. Empty objects and arrays are written as {} and []. Columns appear in the order their keys are first seen across all records, a record that lacks a key gets an empty cell, and null is written as an empty cell too.

Output follows RFC 4180: a field is quoted only when it contains the delimiter, a double quote or a line break, inner quotes are doubled, and records end with CRLF. Excel-friendly download (UTF-8 BOM) prefixes the downloaded file with the three bytes EF BB BF, the signal Excel needs to read it as UTF-8 rather than the system's legacy code page. Leave it off for scripts and databases, where a BOM can end up glued to the first column name.

Protect against formula injection is on by default. A cell whose text starts with =, +, -, @, a tab or a carriage return could run as a formula when the file is opened in Excel, LibreOffice or Google Sheets, so it is written with a single quote in front, such as '=HYPERLINK(...), and the spreadsheet shows it as text. Signed numbers such as -5 or +1.5 are not changed.

Come usare questo strumento

  1. Paste your JSON into the JSON box or use Open file; Sample loads three records with nested fields.
  2. Choose the Delimiter: Comma, Semicolon, Tab or Pipe.
  3. Keep Flatten nested objects on, and under Arrays pick JSON text or Column per item.
  4. In Columns to include, click a column to drop it or bring it back, or use All and None.
  5. Switch on Excel-friendly download (UTF-8 BOM) if the file is meant for Excel, keep Protect against formula injection on for spreadsheets, then press Copy or Download.

What to watch for

  • Whole numbers keep every digit, so a 64-bit ID such as 12345678901234567890 is written exactly. Decimal numbers with more than about 17 significant digits are rounded to what the browser can hold, so send high-precision amounts as strings in the source.
  • The column picker is shown for up to 200 columns; wider data is always written with every column.
  • The quote added by Protect against formula injection becomes part of the cell text. Switch the option off when the CSV goes to a script or database rather than a spreadsheet, and the cells are written exactly as they are.
  • If an object repeats a key, only the last value is kept, as in most JSON parsers.
  • Pasted text is limited to 10,000,000 characters, and Open file accepts files up to 10 MB.

Domande frequenti

My JSON is an object, not an array. Will it work?

Yes. If the object has exactly one array property with items, such as {"items": [...]}, that array is converted and a note names the key. Otherwise the whole object becomes one row, with its nested fields flattened into columns.

Why does Excel show garbled characters instead of accents?

Without a byte order mark, Excel often decodes a CSV with a legacy Windows code page, so letters such as é or Arabic script appear as junk. Turn on Excel-friendly download (UTF-8 BOM) before downloading, or import the file through Data, From Text/CSV and pick UTF-8 there.

Should I use semicolons instead of commas?

Use Semicolon if the file will be double-clicked in Excel on a computer set to a region that writes decimals with a comma, as in much of continental Europe; Excel there expects semicolons as the list separator. For code, APIs and databases, comma is the safe default.

Can I turn the CSV back into the same JSON?

Largely. Open it in CSV to JSON with Nest dotted keys on: address.city becomes a nested object again and tags.0, tags.1 become an array. Cells that held JSON text come back as strings and missing keys as null.