Paste your CSV below to convert it to JSON:

Loading...

How CSV to JSON Conversion Works

This tool converts CSV (Comma-Separated Values) data into a JSON array of objects. Each row becomes an object, and each column header becomes a property name. It automatically detects numbers, booleans, and null values.

Example Conversion

Input CSV:

name,email,age,active
Alice,alice@example.com,30,true
Bob,bob@example.com,25,false

Output JSON:

[
  {
    "name": "Alice",
    "email": "alice@example.com",
    "age": 30,
    "active": true
  },
  {
    "name": "Bob",
    "email": "bob@example.com",
    "age": 25,
    "active": false
  }
]

Automatic Type Detection

The converter automatically parses:

CSV ValueJSON Type
123, 45.67Number
true, falseBoolean
nullNull
Everything elseString

Handling Special Cases

Quoted Fields

Fields containing commas or newlines should be wrapped in double quotes:

name,description
"Acme, Inc.","A company that makes ""everything"""

No Header Row

If your CSV doesn't have headers, uncheck "First row is headers" and columns will be named column1, column2, etc.

Different Delimiters

Not all CSV files use commas. European systems often use semicolons because comma is the decimal separator. Select the appropriate delimiter from the dropdown.

Common Use Cases

  • API payload preparation โ€” Convert spreadsheet data to JSON for API requests
  • Database seeding โ€” Transform CSV exports into JSON for MongoDB or other document databases
  • Configuration files โ€” Convert tabular config data to JSON format
  • Data transformation โ€” Intermediate step in ETL pipelines

Programmatic Conversion

JavaScript

function csvToJson(csv) {
  const lines = csv.trim().split('\n');
  const headers = lines[0].split(',');
  
  return lines.slice(1).map(line => {
    const values = line.split(',');
    return headers.reduce((obj, header, i) => {
      obj[header] = values[i];
      return obj;
    }, {});
  });
}

Python

import csv
import json

def csv_to_json(csv_string):
    reader = csv.DictReader(csv_string.splitlines())
    return json.dumps(list(reader), indent=2)

Pro Tips

  • ๐Ÿ’ก Clean your data first โ€” Remove empty rows and fix inconsistent quoting before converting
  • ๐Ÿ’ก Check for BOM โ€” Excel sometimes adds a byte-order mark that can corrupt the first header
  • ๐Ÿ’ก Validate after โ€” Use the JSON Validator to ensure your output is valid

Related Tools