I converted an API response to CSV and got one row with dozens of columns instead of one row per order. Why?
Because the whole response is one object wrapping the list of orders, and the tool writes a single object as a single row, flattening the orders inside it into columns like orders.0.id and orders.1.id. Copy only the inner array, from the [ to its matching ], and each order becomes its own row.
The response shape that causes it
Most platform APIs do not return the order list bare. They put it inside an object alongside extra information such as a result count or page number. A cut-down example:
{"count":2,"orders":[{"id":1},{"id":2}]}
The tool converted it into one row with three columns, with a note saying the input is a single object, so it was written as one row:
count,orders.0.id,orders.1.id
2,1,2
With two orders the problem looks small. A response with 50 orders of ten fields each, though, gives one row with hundreds of columns, which is what you saw.
The fix: paste the list on its own
When we pasted only the inner array:
[{"id":1},{"id":2}]
out came two rows in a single column named id: one row per order, as expected.
- If the response is long, paste it into the JSON formatter and validator first so it is indented and you can see where the order list starts and ends.
- Copy from the [ right after the list's name, such as "orders":, to the ] that closes it.
- In the CSV and JSON converter, choose 'JSON to CSV' and paste what you copied.
- Check that the row count in the summary equals the number of orders.
What you lose by taking only the list
You lose fields that sat outside the list, such as count or the page number. These usually describe the response, not the orders, so you do not need them in the table. If there is something you do want on every row, such as a store name, add it yourself in the spreadsheet after converting, because the tool does not copy wrapper fields onto each row.
Related cases
- If the response is paginated, each page is its own response. Convert each page's list and combine the files, or merge the lists into one array before converting.
- If the list is nested two levels deep, such as data then orders, the principle is the same: copy the array whose items are the orders.
- If each order holds a list of products, you will then meet the many-product-columns question, and can pick 'JSON text in one cell' under 'Nested values' to keep each order's products in one cell.
Remember that the tool accepts an array of objects, an array of arrays, an array of simple values, or a single object. A single object is always accepted, but by definition it means a single row.
Common questions
Why doesn't the tool find the inner list by itself?
Because an object can contain more than one list, and the tool cannot know which you mean. So it writes what you paste as it is and tells you it is a single object.
Do I need code to extract the list?
No, copying from [ to ] is enough. Formatting the response first makes that easier.
Is the order data sent to a server?
No, the conversion runs in your browser.
