🛠️DevTools

Spreadsheet to JSON

Export data from Google Sheets or Excel as CSV, then convert to JSON for API consumption.

Switch tool:
Examples:
JSON output will appear here...

💡 Paste CSV data and it converts to JSON automatically. First row should contain column headers.

Code Examples

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

1// Convert CSV to JSON array
2function csvToJson(csv) {
3 const lines = csv.trim().split('\n');
4 const headers = lines[0].split(',');
5 return lines.slice(1).map(line => {
6 const values = line.split(',');
7 return headers.reduce((obj, h, i) => ({ ...obj, [h]: values[i] }), {});
8 });
9}
10
11const csv = `date,category,amount
122024-01-15,Sales,1500.00
132024-01-16,Marketing,750.50`;
14const json = csvToJson(csv);
15console.log(JSON.stringify(json, null, 2));

More CSV Examples

Related CSV Tools

📚 Learn More