🛠️DevTools

User CSV to JSON

This converts a CSV with user data to a JSON array, ready for use in APIs or applications.

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 = `id,name,email,active
121,John Doe,john@example.com,true
132,Jane Smith,jane@example.com,false`;
14const json = csvToJson(csv);
15console.log(JSON.stringify(json, null, 2));

More CSV Examples

Related CSV Tools

📚 Learn More