CSV to JSON

Convert CSV to JSON with smart delimiter and type detection.

Runs in your browser Instant No sign-up
Indent
CSV input
JSON
Reverse

Paste, type or drop a file — output appears as you type.

Waiting for input
Processed locally · nothing is uploadedProcessed locally

How to use the CSV to JSON converter

  1. Paste CSV or drop a .csv file into the left pane. Exports from Excel, Google Sheets and databases all work, and a UTF-8 byte order mark is ignored.
  2. Delimiter: Auto-detect, comma, semicolon, tab or pipe.
  3. First row is header: on gives an array of objects keyed by column name; off gives an array of arrays.
  4. Detect numbers & booleans: turns 42, -20, 1250.50, true and false into JSON numbers and booleans, and empty cells into null. Off keeps every value as a string.
  5. Indent the JSON or Minify it, then Copy or Download it as data.json.

Example

id;name;zip;balance;active;note
1;Ada Lovelace;01234;1250.50;true;"Wrote the first
algorithm"
2;"Nguyen, Linh";100000;-20;false;

becomes

[
  { "id": 1, "name": "Ada Lovelace", "zip": "01234", "balance": 1250.5, "active": true, "note": "Wrote the first\nalgorithm" },
  { "id": 2, "name": "Nguyen, Linh", "zip": 100000, "balance": -20, "active": false, "note": null }
]

The delimiter was detected as a semicolon, the quoted multi-line note stayed in one field, and 01234 kept its leading zero.

Type detection rules

Cell JSON value
42, -20, 1.50, 1e3 42, -20, 1.5, 1000
01234, +5, 7 (leading space) strings, unchanged
true, false booleans
empty null
9007199254740993 kept exact, not rounded

Headers

  • Header names are trimmed of surrounding spaces.
  • Empty header cells are named by position: column1, column2, and so on.
  • Duplicate header names trigger a warning, and the value from the later column wins.

Common errors

  • Unterminated quoted field: a " opens a field that never closes. The error points to where the quote opened.
  • Unexpected character after closing quote: text like "x"y. A quote inside a quoted field must be doubled: "x""y".

When to use it

Typical jobs are turning a spreadsheet export into test fixtures or seed data, feeding a CSV report to an API that only accepts JSON, and inspecting a database dump before you write an import script. Paste the file, check the status bar for the record count and the detected delimiter, and read any warnings about ragged rows before you copy the result.

For a large export, open the result in the JSON Viewer to browse records as a collapsible tree instead of scrolling through thousands of lines. To compare two exports of the same table, convert both and paste them into JSON Diff, which lists every changed field by path.

Converting in code

# Python standard library — every value stays a string
import csv, json

with open("data.csv", newline="", encoding="utf-8-sig") as f:
    rows = list(csv.DictReader(f))
print(json.dumps(rows, indent=2, ensure_ascii=False))
# pandas — infers types, but drops leading zeros unless you set dtype
import pandas as pd

pd.read_csv("data.csv", dtype={"zip": str}).to_json("data.json", orient="records", force_ascii=False)

To go back to a spreadsheet, click Reverse above the output or open JSON to CSV. To type the result for your code, paste it into JSON to TypeScript.

Frequently asked questions

How does delimiter auto-detection work?

It looks at the first ten lines and counts commas, semicolons, tabs and pipes, then picks the character that appears the same number of times on the most lines. If the guess is wrong, for example when a comma-separated file also has semicolons in every row, choose the delimiter manually. The status bar shows which one was used.

Why is "01234" still a string but "100000" became a number?

With "Detect numbers & booleans" on, a value becomes a number only if it is a valid JSON number with no leading zeros. That keeps ZIP codes, phone numbers and IDs like 007 as strings. "true" and "false" become booleans, and empty cells become null. Turn detection off to keep every value as a string.

Does it handle commas and line breaks inside fields?

Yes. It follows RFC 4180: a field wrapped in double quotes can contain the delimiter, line breaks and escaped quotes ("" for one "). A quote that is never closed is reported with the line and column where it opened.

What about rows with missing or extra columns?

They are still converted. Missing cells become null (or an empty string with type detection off), extra cells are dropped, and a warning lists the affected row numbers.

Is my CSV uploaded?

No. Parsing happens in your browser, and nothing is uploaded.

Last updated