{}JSONLint.app

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

Common Mistakes & Pro Tips

  • Everything is a string unless you opt into type inferenceCSV has no type system, so a raw parse turns 42, true, and 2024-01-01 all into JSON strings. If you want "age": 30 instead of "age": "30", enable numeric/boolean inference, but be aware it will also coerce values you may want to keep as text, such as ZIP codes and phone numbers.
  • Leading zeros and big numbers get destroyed by inferenceA value like 007 becomes 7 and a 16-digit account number like 1234567890123456 can lose precision because JSON numbers are IEEE-754 doubles (safe only up to 9007199254740991). Keep identifier-like columns as strings rather than auto-converting them to numbers.
  • The first row is treated as headers — make sure that's what you wantEach header cell becomes an object key, so a missing or duplicated header row produces wrong or colliding keys (the second "id" column overwrites the first). If your file has no header row, you'll get keys like "col1" or your first data row consumed as keys instead.
  • Quoted fields can legally contain commas and newlinesPer RFC 4180, a field wrapped in double quotes may contain commas, line breaks, and escaped quotes ("" represents a literal "). A naive split on commas or newlines will shred these rows, so always use a real CSV parser rather than splitting strings yourself.
  • Delimiter and encoding aren't always commas/UTF-8European exports often use semicolons because the comma is the decimal separator, and tab-separated (TSV) files are common too. Also watch for a UTF-8 BOM (the invisible \uFEFF) at the start of the file, which can attach itself to your first header key as "\uFEFFid".

Frequently Asked Questions

How do I convert CSV to a JSON array of objects?

Paste or upload your CSV; the first row is read as field names and every subsequent row becomes one object whose keys are those names. The result is a JSON array like [{"name":"Ann","age":"30"}, ...]. By default values stay as strings; enable type inference if you want numbers and booleans parsed.

Why are my numbers showing up as strings in the JSON?

CSV stores no type information, so a safe default keeps every cell as a string to avoid silently corrupting data like leading-zero IDs or phone numbers. Turn on type inference to convert numeric and boolean-looking values, or post-process the specific columns you know are numeric.

How are empty cells handled?

An empty cell is typically converted to an empty string "", not to JSON null, because CSV cannot distinguish "blank" from "null." If you need true nulls, convert empty strings afterward, but note this also affects intentionally blank text fields.

Can it handle semicolon or tab delimited files?

Yes. Many converters auto-detect the delimiter by sampling the first lines, and most let you set it explicitly to comma, semicolon, tab, or pipe. If detection guesses wrong (common when one column contains many semicolons), override it manually.

What happens to fields that contain commas or quotes?

As long as those fields are wrapped in double quotes per the CSV standard, they are preserved correctly: "Smith, John" stays one value and "" inside a quoted field becomes a single literal quote. Problems only arise if the source file isn't properly quoted to begin with.

Is my CSV uploaded to a server?

No. The conversion runs entirely in your browser using JavaScript, so the file never leaves your machine and nothing is sent over the network. This makes it safe for confidential exports such as customer lists or financial data.