JSON to CSV

Convert JSON array to CSV string.

Code

Utilities
const headers = Object.keys(json[0]);
return [headers.join(','), ...json.map(obj => headers.map(h => obj[h]).join(','))].join('\n');

Parameters

Array of objects to convert.

Browser·fetch() may be limited by CORS

More JavaScript Snippets