🛠️DevTools

Nested JSON to CSV

Nested objects are flattened using dot notation, making them easy to work with in spreadsheets.

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 = `[{"user": {"name": "John", "email": "john@example.com"}, "orders": 5}, {"user": {"name": "Jane", "email": "jane@example.com"}, "orders": 3}]`;
10console.log(jsonToCsv(input));
11
12// Output:
13// user.name,user.email,orders
14// John,john@example.com,5
15// Jane,jane@example.com,3

More JSON Examples

Related JSON Tools

📚 Learn More