How to Convert CSV to JSON: A Simple Step-by-Step Guide
Converting CSV to JSON usually uses the first CSV row as property names and turns each following row into a JSON object. The objects are collected in a JSON array.
By Archana Bhandari ยท
A quick CSV to JSON example
JSONPlease preserves CSV values as strings, so ages remain quoted in the output. Already have CSV data? Paste it into the JSONPlease CSV to JSON Converter to convert it directly in your browser. It also supports opening a CSV file, copying, and downloading the JSON.
CSV:
name,age,city
Rahul,28,Dehradun
Amit,31,Delhi
JSONPlease output:
[
{
"name": "Rahul",
"age": "28",
"city": "Dehradun"
},
{
"name": "Amit",
"age": "31",
"city": "Delhi"
}
]What is CSV?
CSV stands for Comma-Separated Values. It is a plain-text table format. The first row normally contains headers or column names; the following rows contain records.
name,city,age
Rahul,Dehradun,28
Amit,Delhi,31What is JSON?
JSON represents structured data with objects, arrays, keys, and values. In a CSV conversion, each row normally becomes one object and the full set of rows becomes an array.
{
"name": "Rahul",
"city": "Dehradun",
"age": "28"
}How CSV becomes JSON
Headers name and city become JSON keys. The first data row becomes one object, the second row becomes another object, and both objects go inside an array.
CSV:
name,city
Rahul,Dehradun
Amit,Delhi
JSON:
[
{ "name": "Rahul", "city": "Dehradun" },
{ "name": "Amit", "city": "Delhi" }
]How to convert CSV to JSON online
Open JSONPlease CSV to JSON Converter, paste CSV data or choose Open file, select Convert, review the formatted JSON output, then copy or download it if needed. The conversion happens locally in your browser.
CSV to JSON product example
Values such as 799 and true remain strings because CSV does not carry reliable JSON type information. This protects values like codes and identifiers from unwanted type changes.
CSV:
product_id,product_name,price,in_stock
101,Wireless Mouse,799,true
102,Keyboard,1299,false
JSONPlease output:
[
{
"product_id": "101",
"product_name": "Wireless Mouse",
"price": "799",
"in_stock": "true"
},
{
"product_id": "102",
"product_name": "Keyboard",
"price": "1299",
"in_stock": "false"
}
]What happens to CSV headers?
The first row provides JSON property names. Good headers are clear, unique, and not blank. For example, name,email,city becomes the keys "name", "email", and "city" in every output object.
- Use clear names that match the destination system.
- Avoid accidental blank headers.
- Keep headers unique.
What happens if CSV has duplicate headers?
JSONPlease rejects duplicate CSV headers because two distinct columns cannot safely use the same object key. Rename them before converting.
Rejected CSV:
name,email,email
Rahul,personal@example.com,work@example.com
Use instead:
name,personal_email,work_email
Rahul,personal@example.com,work@example.comWhat happens to empty CSV cells?
JSONPlease represents an empty cell as an empty string. If a data row is shorter than the header row, the missing trailing columns also become empty strings. This is different from null: null is a JSON value, while an empty CSV cell has no text.
CSV:
name,age,city
Rahul,28,
Amit,,Delhi
JSONPlease output:
[
{ "name": "Rahul", "age": "28", "city": "" },
{ "name": "Amit", "age": "", "city": "Delhi" }
]What happens to numbers and true or false?
CSV has no strong JSON-style type information, so JSONPlease preserves numbers, decimals, true, false, and null-like text as strings. This also preserves leading-zero values such as 00123 exactly. That matters for postal codes, product IDs, account references, and phone-like identifiers.
CSV:
id,price,active,value
00123,799,true,null
JSONPlease output:
[
{
"id": "00123",
"price": "799",
"active": "true",
"value": "null"
}
]CSV values containing commas
A comma inside a quoted CSV field is part of that value, not another column. A CSV parser must handle this; splitting lines only on commas is not enough.
CSV:
name,address
Rahul,"Rajpur Road, Dehradun"
Amit,"Connaught Place, Delhi"
JSONPlease output:
[
{ "name": "Rahul", "address": "Rajpur Road, Dehradun" },
{ "name": "Amit", "address": "Connaught Place, Delhi" }
]CSV values containing double quotes or new lines
CSV escapes a double quote inside a quoted field by doubling it. Properly quoted fields can also contain line breaks; JSONPlease preserves those line breaks in the resulting string.
CSV:
name,message,note
Rahul,"He said ""Hello"" to me","first line
second line"
JSONPlease output:
[
{
"name": "Rahul",
"message": "He said \"Hello\" to me",
"note": "first line\nsecond line"
}
]Convert Excel CSV or Google Sheets CSV to JSON
Export the required worksheet or sheet as CSV, then open or paste that CSV into JSONPlease. CSV represents one flat table; it does not preserve multiple sheets, formulas, formatting, colours, charts, or other workbook features. For actual XLS or XLSX files, use the published Excel to JSON Converter.
Convert database export CSV to JSON
Many systems can export a table as CSV. Each exported row becomes a JSON object. Conversion creates valid JSON structure, but it does not guarantee that the field names or string values match another application's API requirements.
CSV:
id,name,email
1,Rahul,rahul@example.com
2,Amit,amit@example.com
JSON:
[
{ "id": "1", "name": "Rahul", "email": "rahul@example.com" },
{ "id": "2", "name": "Amit", "email": "amit@example.com" }
]CSV to JSON for APIs
An API may expect JSON objects while existing data is exported as CSV. Conversion is only the first step: the API may require particular property names, data types, required fields, authentication, or a different nested structure. Valid JSON conversion does not automatically meet those requirements.
Can CSV represent nested JSON?
CSV is fundamentally tabular, while JSON can naturally contain nested objects and arrays. There is no single universal CSV form for every nested JSON document. A flat CSV conversion produces flat row objects unless you apply separate conventions or transformations.
Nested JSON example:
{
"name": "Rahul",
"address": {
"city": "Dehradun",
"country": "India"
}
}Validate and format converted JSON
The converter produces formatted JSON output. Validate it if you plan to edit it manually or send it to another system, and use a formatter later if the JSON becomes minified or difficult to read.
Common CSV to JSON conversion problems
Duplicate headers are rejected; rename them. Empty headers are still keys, so correct accidental blank headers before conversion. Quoted commas, quotes, and new lines must use valid CSV quoting. Short rows get empty-string values; leading zeros stay strings. Character encoding, very large files, unexpected extra columns, and expecting nested JSON from a flat table are separate data-quality concerns to check before importing.
- Use a proper CSV parser rather than splitting on commas.
- Review output types; all CSV values are strings in JSONPlease.
- Check that the JSON structure matches the destination application.
CSV to JSON conversion checklist
Use this before sending converted data elsewhere.
- Does the CSV have a header row?
- Are header names unique and non-blank?
- Are commas inside values properly quoted?
- Are double quotes escaped correctly?
- Should leading-zero values remain strings?
- Are empty cells handled as expected?
- Does the resulting JSON structure match the application or API?
- Is the resulting JSON valid?
Frequently asked questions
How do I convert CSV to JSON? Use the first row as keys and turn each later row into an object in an array.
Do CSV headers become JSON keys? Yes, in JSONPlease's conversion.
Do CSV rows become JSON objects? Yes.
Can I convert a CSV file to JSON? Yes, open a CSV file in the converter or paste its text.
Can I convert Excel or Google Sheets data? Export the needed sheet as CSV first, then convert it.
How are commas inside values handled? They stay inside a properly quoted CSV field.
What happens to empty cells? They become empty strings.
What happens to numbers? JSONPlease preserves them as strings.
How do I keep leading zeros? They are already preserved as strings.
Can CSV become nested JSON? Not automatically from a plain flat table.
How do I check converted JSON? Review it and run it through a JSON validator if needed.