🛠️DevTools

API Response to CSV

Export API response data to CSV for analysis in spreadsheet applications.

Switch tool:
Examples:

💡 Paste a JSON array and it converts to CSV automatically. Download for use in Excel or Google Sheets.

Code Examples

Here's how to achieve this in different programming languages:

1// Convert JSON array to CSV
2function jsonToCsv(jsonData) {
3 const data = JSON.parse(jsonData);
4 const headers = Object.keys(data[0]);
5 const rows = data.map(obj => headers.map(h => obj[h]).join(','));
6 return [headers.join(','), ...rows].join('\n');
7}
8
9const input = `[{"id": 1, "title": "Post 1", "views": 1500, "published": true}, {"id": 2, "title": "Post 2", "views": 2300, "published": true}, {"id": 3, "title": "Draft", "views": 0, "published": false}]`;
10console.log(jsonToCsv(input));
11
12// Output:
13// id,title,views,published
14// 1,Post 1,1500,true
15// 2,Post 2,2300,true
16// 3,Draft,0,false

More JSON Examples

Related JSON Tools

📚 Learn More