CSV to JSON
Paste CSV or spreadsheet rows. Get JSON with real types and nested keys. Nothing leaves your browser.
- 0
- Rows
- 0
- Columns
- 0
- Errors
On this page
About CSV to JSON Converter
Updated
CSV to JSON Converter turns CSV (comma-separated values) into JSON (JavaScript Object Notation), the format that APIs and code read. Paste a CSV file or rows from a spreadsheet, and the JSON shows as you type. Copy it, or download it as a .json file.
The converter gives each column one type: numbers, true/false or text. A zip code with a leading 0 keeps its 0. Headers such as address.city become nested objects. When a row is broken, the converter rings the exact spot, gives its line, and says how to fix it.
How to use it
- Paste CSV, paste rows from Excel or Google Sheets, drop a file, or pick an example.
- Pick the shape of the JSON in the Result header (on a phone, in Options): an array of objects, an object keyed by the first column, JSON Lines, arrays, or column arrays.
- Open Columns to leave out a column, or to keep a column of numbers as text.
- Open Options for empty cells, nested keys, key style, the header row, JSON in cells, spaces and indent.
- Press Copy or Download in the Result pane. Both take the JSON, in every view.
How CSV becomes JSON
Each row is an object
The first row holds the column names. Each row after it becomes an object, with a key for each column. Without a header row, turn off Header in Options; the keys are then column1, column2 and so on.
id,name,active
1,Ada,true
2,Alan,false[
{ "id": 1, "name": "Ada", "active": true },
{ "id": 2, "name": "Alan", "active": false }
]One type per column
A column becomes numbers only when every value in it is a JSON number. When one value is not, such as 02108, 1,5 or n/a, the whole column stays text, and Notes names that value. A column of true and false (in any case, such as TRUE from Excel) becomes true and false. Choose All text in Options to keep every value as text.
city,zip
New York,10001
Boston,02108[
{ "city": "New York", "zip": "10001" },
{ "city": "Boston", "zip": "02108" }
]Numbers keep the digits they have in the CSV, so 19.90 stays 19.90 and a 20-digit ID keeps every digit. JavaScript reads whole numbers past 9007199254740991 rounded, so Notes warns about such a column. Set it to text in Columns to keep it exact in code.
Empty cells
An empty cell becomes null by default, so a number column holds only numbers and null. In Options, choose "" for empty text, or Leave out to leave the key out of that object. The word null in a number or true/false column is null too.
Nested objects and arrays
A dot in a column name makes a nested object. A number after the last dot makes an array. These are the names that our JSON to CSV converter writes, so a CSV made there comes back as the same JSON. One thing changes: an empty text value comes back as null. To keep it as empty text, set Empty cells to "" in Options. An array ends at its last value, so a short list stays short.
id,address.city,address.zip,tags.0,tags.1
1,London,W1,math,poetry
2,Boston,02108,navy,[
{ "id": 1, "address": { "city": "London", "zip": "W1" }, "tags": ["math", "poetry"] },
{ "id": 2, "address": { "city": "Boston", "zip": "02108" }, "tags": ["navy"] }
]When a column has the same name as the start of another, such as address and address.city, the second one stays one flat key, and Notes says so. Turn off Nested keys in Options to keep every key flat.
Five shapes
- Array of objects: one object per row. The usual choice.
- Keyed by first column: one object, with the first column as the key, such as
{ "SE": { "name": "Sweden" } }. Good for lookups. When a key is used twice, the JSON keeps the last row, and Notes names the lines. - JSON Lines: one object per line, with no array around them. For logs, BigQuery and data pipelines.
- Array of arrays: the header row, then one array per row, such as
[["id","name"],[1,"Ada"]]. - Column arrays: one key per column with all its values, such as
{ "id": [1, 2] }. For charts and data tools.
A column name used twice
When two columns have the same name, the second one gets a number, such as sku_2. No value is lost, and Notes shows where the name repeats.
Key style
Under Key style in Options, keys can be written as camelCase, snake_case or lowercase. First Name then becomes firstName, first_name or first name. The parts of a nested key change one by one.
From Excel or Google Sheets
Select the cells, header row included, and copy them. Paste them into the editor. A spreadsheet copies cells as text with a tab between them, and the converter finds the tab by itself. Dates come as you see them in the sheet, such as 2026-03-01, and stay text. For a whole sheet, save it as CSV first: in Excel, File > Save As > CSV UTF-8. In Google Sheets, File > Download > Comma-separated values.
TSV to JSON
TSV (Tab-Separated Values) is CSV with a tab between the fields. Paste or drop a .tsv file as it is: the converter finds the tab by itself, and every rule on this page works the same way. To set it by hand, pick Tab in Read with, in Options.
Common errors
The converter does not guess when a row is broken. It rings every broken row in the editor, lists them all, and makes JSON only when the CSV is right. A guess would put values under the wrong keys without a word. When you need the JSON now, press Convert anyway on the error: a short row gets empty values at the end, extra fields are left out, and Notes lists every row it changed. A quote that never closes has no safe fix, so you must close it first.
A row with an extra field
Every row needs as many fields as the header. A comma inside a value splits it in two. Put that value in double quotes.
name,role
Hopper, Grace,adminname,role
"Hopper, Grace",adminA row with a missing field
Write an empty field with two delimiters next to each other, so the values after it stay in their columns.
id,name,email
3,linus@example.comid,name,email
3,,linus@example.comA quote that never closes
A field that starts with a double quote must end with one. Without it, the rest of the file reads as one field. The converter rings the quote that opens it.
id,name
4,"Margaret Hamilton
5,Alan Turingid,name
4,"Margaret Hamilton"
5,Alan TuringA quote inside a quoted field
Inside a quoted field, write each double quote twice, as RFC 4180 says. A single one ends the field too soon.
id,quote
1,"He said "hi" and left"id,quote
1,"He said ""hi"" and left"In code
To convert in a script, Python and JavaScript need only a few lines. Both give every value as text; this page finds the types for you.
import csv, json
with open("data.csv", newline="", encoding="utf-8-sig") as f:
rows = list(csv.DictReader(f))
with open("data.json", "w", encoding="utf-8") as f:
json.dump(rows, f, indent=2, ensure_ascii=False)// Simple CSV only: no commas or line breaks inside quotes.
const [head, ...lines] = text.trim().split(/\r?\n/);
const keys = head.split(",");
const rows = lines.map((line) => {
const cells = line.split(",");
return Object.fromEntries(keys.map((k, i) => [k, cells[i]]));
});The JavaScript lines break on quoted fields. For real files, use a CSV library, or paste the file here. utf-8-sig in Python drops the byte order mark that Excel puts at the start of a CSV UTF-8 file.
Behind the scenes
Our own CSV reader follows RFC 4180, the same one as in the CSV Formatter, so every error has an exact place. It finds the delimiter from the first 20 lines. The JSON is written by hand, so numbers keep their digits. A background thread converts big files, so the page does not freeze. To go the other way, use JSON to CSV. To check the JSON after, use the JSON Validator or the JSON Viewer.
CSV and JSON resources
- RFC 4180The common format for CSV files: commas, double quotes and line breaks.
- JSON LinesThe format with one JSON value on each line, also called JSONL or NDJSON.
- The JSON WebsiteThe official website for JSON, with the full syntax.
- RFC 8259The IETF standard that defines the JSON data format.
- Python: the csv modulecsv.DictReader reads each row of a CSV file into a dict.
- MDN: Number.MAX_SAFE_INTEGERWhy JavaScript reads whole numbers past 9007199254740991 rounded.
CSV to JSON FAQ
How do I convert CSV data to JSON?
Paste the CSV into the editor, or drop the .csv file on it. The JSON shows in the Result pane as you type. Each row becomes an object, and each column name becomes a key. Press Copy, or Download to save a .json file. Your browser does the work, and nothing is uploaded.
How do I convert Excel to JSON?
Select the cells in Excel, including the header row, and copy them. Paste them into the editor. Excel copies cells as text with a tab between them, and the converter finds the tab by itself. TRUE and FALSE become true and false. To convert a whole file, save it in Excel as CSV UTF-8 and drop that file here.
Why is my zip code a string and not a number?
A number in JSON cannot start with 0, so 02108 can only stay what it is as text. The converter gives each column one type, so when one zip code has a leading 0, the whole column is text. Notes names the value that made it text. Your code then gets the same type on every row.
How do I make nested JSON from CSV?
Name the columns with dots: address.city and address.zip go into one address object. Numbers as the last part make an array: tags.0 and tags.1 become a tags list. This is on by default. Turn off Nested keys in Options to keep keys such as address.city flat.
Can you give a Python script that converts a CSV file to JSON?
Yes. The csv and json modules in Python's standard library do it in a few lines; see the script under In code, on this page. Note that csv.DictReader gives every value as text. To get numbers and true/false, convert them yourself, or use this page, which finds one type per column.
Why use JSON instead of CSV?
JSON keeps types and structure: a number, true or null stays what it is, and data can be nested. CSV is one flat table of text, which every spreadsheet opens. Use JSON for APIs, configuration and code. Use CSV when people sort and filter the data in a spreadsheet.
What is the difference between JSON and JSON Lines?
JSON puts all rows in one array. JSON Lines (JSONL or NDJSON) puts one JSON object on each line, with no array around them. Logs, BigQuery and many data tools read JSON Lines, because a program can read one line at a time. Pick JSON Lines in the Shape list in the Result header, or in Options on a phone.
Is my CSV uploaded anywhere?
No. The conversion runs in your browser, even for big files. There are no ads, no sign-up and no cookie banner.