Skip to content
LocalOnly

CSV to JSON Converter

Stable

Parse CSV into a clean array of typed JSON objects, header-aware.

Everything is processed locally in your browser

About CSV to JSON Converter

Convert CSV into a tidy array of JSON objects, with the first row used as keys for every record. This CSV to JSON converter respects quoted fields, embedded commas and multi-line cells, and can infer numbers and booleans so your JSON isn't wall-to-wall strings. It handles comma, semicolon and tab-delimited files, making it a drop-in tool for messy exports from any spreadsheet or database.

Features

  • Uses the header row as object keys for every generated record
  • Correctly parses quoted fields with embedded commas, quotes and newlines
  • Optional type inference converts numbers, booleans and null automatically
  • Auto-detects or lets you set the delimiter (comma, semicolon, tab)
  • Handles trailing newlines and blank lines without producing empty rows
  • Outputs pretty or minified JSON, ready to paste into code

How to use CSV to JSON Converter

  1. 1

    Paste your CSV

    Paste CSV text with a header row on top. Files exported from Excel, Sheets, or a database all work as-is.

  2. 2

    Pick your options

    Choose a delimiter if it isn't a comma, and toggle type inference to keep numbers and booleans typed rather than stringified.

  3. 3

    Copy the JSON

    Copy the resulting array of objects or download it as a .json file for use in your app or tests.

Examples

CSV to array of objects

The header row becomes keys; type inference types the values.

Input

id,name,active
1,Grace Hopper,true
2,Katherine Johnson,false

Output

[
  { "id": 1, "name": "Grace Hopper", "active": true },
  { "id": 2, "name": "Katherine Johnson", "active": false }
]

How CSV to JSON conversion works

Everything in a CSV is text, so types have to be guessed

A CSV file has no type information whatsoever. Every cell is a sequence of characters, and the difference between the number 42 and the string `"42"` simply is not recorded. JSON, by contrast, requires you to commit to a type for every value. So the conversion has to infer, and inference means guessing.

The usual rules are sensible and mostly right: something that looks like a number becomes a number, `true` and `false` become booleans, an empty cell becomes null or an empty string, and everything else stays a string. For most data this produces what you want without any intervention.

The failures are specific and worth knowing in advance. Identifiers made of digits - postcodes, phone numbers, account numbers, ISBNs - become numbers, which strips leading zeros and, above 15 digits, loses precision entirely. Version strings like `1.10` become the number 1.1. And a column that is numeric in most rows and textual in a few produces mixed types in the JSON, which then breaks strict consumers. When identifiers matter, turning type inference off and keeping everything as strings is the safer default.

CSV is a family of formats, not one format

RFC 4180 describes CSV, but it arrived after the format was already entrenched and it is honoured loosely. Real files vary in delimiter, quoting, line endings and encoding, and a parser has to cope with all of it.

Delimiters are the most visible variation. Comma is standard, but semicolon is normal wherever the decimal separator is a comma - much of Europe - and tab-separated files are common in scientific data. Quoting is the second: a field containing the delimiter must be quoted, and a quote inside a quoted field is escaped by doubling it, so `""` inside quotes means one literal quote character.

Encoding is the one that produces the most confusing symptoms. A UTF-8 byte order mark at the start of a file, which Excel adds when saving as CSV, will otherwise attach itself to the first column name - so `id` silently becomes `\ufeffid` and every lookup for `id` fails. A parser that strips the BOM saves you a genuinely baffling debugging session.

Rebuilding structure from column names

CSV is flat, but headers can encode hierarchy by convention. A column named `user.address.city` describes a path, and interpreting it that way rebuilds the nested object - which is exactly the inverse of what the JSON to CSV tool does when it flattens.

The same notation applies to arrays: `phones[0]` and `phones[1]` become an array of two elements. This makes a round trip through CSV largely faithful, provided the headers were generated rather than typed by hand.

The limitation is the one every dotted-path scheme has: a column name that legitimately contains a dot cannot be distinguished from a nesting separator. If your headers include something like `revenue.2024`, it will become a nested object rather than a single key. Renaming the column is the only reliable fix.

Reference

How cell values are inferred

Cell contentBecomesWatch for
42Number 42Fine unless it is an identifier
007Number 7Leading zeros lost - keep as text
1.10Number 1.1Version strings are corrupted
1234567890123456789Rounded numberPrecision lost above 2^53
trueBoolean trueQuote it if you need the string "true"
(empty)null or ""The two cannot be distinguished afterwards
"a,b"String a,bQuoting protects the delimiter
"say ""hi"""String say "hi"Doubled quotes mean one literal quote
\ufeffidCorrupted key nameA byte order mark from Excel

Which tool should you use?

These tasks overlap. Here is how to pick the right one for what you are actually doing.

You have a clean spreadsheet export to turn into JSON
This is the standard case. Check the inferred types on any identifier columns before you rely on the output.
Your headers use dotted paths like `user.city`
They will be rebuilt as nested objects automatically, which reverses a JSON to CSV conversion faithfully.
The data contains postcodes, phone numbers or long IDs
Disable type inference and keep everything as strings. Leading zeros and precision cannot be recovered once lost.
You already have flat JSON rather than CSV
The JSON Unflatten tool rebuilds nesting from dotted keys without the CSV parsing step.

Use cases

  • Turn a spreadsheet export into JSON seed data for an app
  • Convert a CSV report into JSON for a frontend or API
  • Reshape a database CSV dump into structured JSON records
  • Prototype quickly by pasting CSV and consuming JSON immediately
  • Feed CSV survey results into a JSON-based analytics pipeline

Troubleshooting common errors

The first column name has an invisible character

Why: A UTF-8 byte order mark, added by Excel when saving as CSV.

Fix: Strip it before parsing, or re-save the file as UTF-8 without BOM. This one is genuinely hard to spot because the character is invisible.

Every row parsed into a single field

Why: The file uses semicolons or tabs rather than commas.

Fix: Set the delimiter to match the file. Semicolons are standard in European locales.

Leading zeros vanished from postcodes

Why: The values were inferred as numbers.

Fix: Turn off type inference so they stay strings. There is no way to restore the zeros afterwards.

A row has more fields than the header

Why: Usually an unquoted delimiter inside a field - a comma in an address, for instance.

Fix: Quote fields containing the delimiter in the source file. This is malformed CSV, and different parsers will disagree about how to recover.

Multi-line values broke the row structure

Why: A newline inside a field that was not quoted.

Fix: Quote any field containing a newline. Properly quoted multi-line fields parse correctly.

Limitations

What this tool deliberately does not do, so you know when to reach for something else.

  • Type inference is heuristic and will misread identifiers made of digits.
  • Null and empty string are indistinguishable in CSV, so one interpretation must be chosen.
  • Column names containing dots cannot be told apart from nesting separators.
  • Malformed rows with inconsistent field counts cannot be recovered reliably.
  • Precision above 2^53 is lost when a long numeric string is inferred as a number.

Frequently asked questions

Learn more

Command Palette

Search for a tool or command