CSV to JSON Converter

CSV Input
1
JSON Output

Last updated:

Jsonic's CSV to JSON converter transforms CSV data into a JSON array of objects. The first row is treated as column headers. Numeric strings are automatically coerced to JSON numbers. Quoted fields containing commas or line breaks are handled correctly. Each row becomes one JSON object. The result can be copied or downloaded.

How CSV to JSON conversion works

CSV is a flat table; JSON is structured. The conversion maps each CSV row to one JSON object and wraps every object in an array. The first row supplies the keys — so a 100-row, 4-column CSV produces a 100-element array, each element an object with the same 4 keys.

id,name,email,active
1,Alice,alice@example.com,true
2,Bob,bob@example.com,false
[
  { "id": 1, "name": "Alice", "email": "alice@example.com", "active": true },
  { "id": 2, "name": "Bob",   "email": "bob@example.com",   "active": false }
]

Quoted fields keep commas and line breaks intact

The hard part of CSV is not splitting on commas — it is the commas, quotes, and newlines that live inside a quoted field. A proper parser keeps a quoted value whole, and de-escapes a doubled quote ("") back to a single quote. Splitting each line with line.split(',') silently corrupts rows like these.

id,note
1,"Hello, world"
2,"Line one
Line two"
3,"She said ""yes"""
[
  { "id": 1, "note": "Hello, world" },
  { "id": 2, "note": "Line one\nLine two" },
  { "id": 3, "note": "She said \"yes\"" }
]

Type coercion: when "42" should and shouldn't become 42

Every CSV cell starts as text. Dynamic typing turns numeric-looking strings into numbers and true/false into booleans — great for quantities and flags. But some columns are numeric by accident: ZIP codes, phone numbers, SKUs, and account numbers must stay strings, or a leading zero like 00123 is lost forever.

age,zip,subscribed
42,00123,true

// Right:  { "age": 42, "zip": "00123", "subscribed": true }
// Wrong:  { "age": 42, "zip": 123,     "subscribed": true }   <- lost leading zero

Clean header names before they become keys

Headers become JSON property names, so a header of First Name yields a key with a space in it — legal JSON, but awkward to access as obj.firstName in code. Trim whitespace and standardize the casing before relying on the output downstream.

First Name,Email Address,Signup Date
Alice,alice@example.com,2024-01-15

// After cleanup the keys read naturally:
// { "firstName": "Alice", "emailAddress": "alice@example.com", "signupDate": "2024-01-15" }

Convert CSV to JSON in code

When you need the conversion inside a script or pipeline rather than the browser tool:

# Python — standard library, no extra packages
import csv, json
with open("data.csv") as f:
    rows = list(csv.DictReader(f))   # first row -> keys
print(json.dumps(rows, indent=2))    # all cells stay strings here
// JavaScript — Papa Parse handles quoting and typing
import Papa from 'papaparse'
const { data } = Papa.parse(csvText, { header: true, dynamicTyping: true })
console.log(JSON.stringify(data, null, 2))
# Command line — pandas keeps ID columns as strings
python -c "import pandas as pd; print(pd.read_csv('data.csv', dtype={'zip': str}).to_json(orient='records', indent=2))"

Common CSV to JSON mistakes

  • Using a naive comma split that breaks quoted fields and multiline cells.
  • Letting every numeric-looking value become a number, dropping leading zeros on IDs and ZIPs.
  • Converting without a header row, so the real first record gets eaten as column names.
  • Leaving empty cells ambiguous instead of deciding between "" and null.
  • Forgetting to validate required fields after conversion.

For a step-by-step walkthrough with more examples, see the CSV to JSON tutorial. To go the other way, use JSON to CSV.

How to convert CSV to JSON

  1. Paste your CSV into the left panel, or load a file.
  2. The first row is treated as column headers.
  3. Click Convert to generate a JSON array.
  4. Each CSV row becomes one JSON object.
  5. Click Copy or Download to save the result.

FAQ

Does the first row need to be headers?

Yes. The first row is treated as column names and becomes the JSON keys.

Are numbers and booleans auto-detected?

Yes. Values that look like numbers (integers or decimals) are converted to number type. "true" and "false" (case-insensitive) become boolean.

How are quoted fields handled?

Fields wrapped in double quotes are supported, including values that contain commas or newlines inside the quotes.

What delimiter does this support?

Standard comma (,) delimiter. Tab-separated files are not currently supported.

Is my data uploaded?

No. Conversion runs entirely in your browser.

Can I download the JSON output?

Yes. Click Download to save the result as a .json file.

What if some rows have missing values?

Missing values (empty cells) are included as empty strings in the output. They are not omitted.