🛠️DevTools

Inventory CSV to JSON

Import inventory data from spreadsheets to JSON for inventory management systems.

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 = `sku,warehouse,quantity,last_updated
12SKU001,NYC,150,2024-01-15
13SKU002,LA,75,2024-01-14`;
14const json = csvToJson(csv);
15console.log(JSON.stringify(json, null, 2));

More CSV Examples

Related CSV Tools

📚 Learn More