convert --to=csvtype a query, e.g. $.users[0].name
IDLE
stdin
1
stdout
Turn an array of JSON objects into CSV you can open in a spreadsheet. Columns are worked out from every row, not just the first, and the conversion runs in your browser.
How rows and columns are built
Each object in the array becomes one row. The header lists every key that appears in any row, in the order it is first seen, and a row without that key gets an empty cell. Nested objects are flattened into dotted names, so an address object with a city key becomes a column called address.city.
Arrays inside a row stay together in one cell, written as JSON, and null becomes an empty cell. An array of arrays is written row by row without a header, a list of plain values gets a single value column, and one object becomes one row.
Quoting and picking the data
Cells that contain commas, double quotes or line breaks, or that start or end with a space, are wrapped in double quotes, with inner quotes doubled. That is the form spreadsheet programs expect.
If your rows sit inside a larger document, type a query such as .users or $.data.items on the prompt line and only that array is converted. Copy the result or save it as a .csv file.
Questions
Why is my output a single row?
One object becomes one row. Point the query at the array that holds your records, for example .results, and each item becomes a row.
What happens to nested arrays?
They stay in one cell as JSON text, so nothing is dropped. To get them as rows of their own, query that array and convert it on its own.
Can it convert CSV to JSON?
Not at the moment. This page goes from JSON to CSV only.
Is my data uploaded?
No. The conversion runs in this page, and nothing you paste is sent anywhere.