Quick answer: To convert CSV to JSON, treat the first row as field names and turn every following row into an object, for example name,age + Ayesha,29 becomes [{"name": "Ayesha", "age": 29}]. Quoted fields may contain commas and line breaks. A free CSV to JSON converter does this instantly and can convert JSON back to CSV.
Spreadsheets export CSV, while web apps and APIs usually want JSON. Converting between the two is one of the most common data chores for developers, analysts and anyone importing a product list or contact sheet into a website. This guide explains both formats, shows exactly how a conversion works, and covers the quoting rules that trip most people up. To convert a file right now, use the free CSV to JSON Converter — it also turns JSON back into CSV.

What is a CSV file?
CSV stands for comma-separated values. It is plain text where each line is one record and each value is separated by a comma:
- The first line is usually a header with the column names, such as
name,email,age. - Every following line holds one row of data:
Ayesha,ayesha@example.com,29. - The common rules were written down in RFC 4180 (2005), which also registered the
text/csvmedia type. Many programs still bend those rules, which is why CSV files from different apps can look slightly different.
What is JSON?
JSON (JavaScript Object Notation) is a text format for structured data. A list of records is written as an array of objects, and each object holds key–value pairs:
- Objects use curly braces:
{"name": "Ayesha", "age": 29}. - Arrays use square brackets:
[ {...}, {...} ]. - Values can be strings in double quotes, numbers,
true,false,null, or nested objects and arrays.
CSV vs JSON: the key differences
- Shape: CSV is a flat table. JSON can be nested, so one record can hold a list of addresses or tags.
- Data types: every CSV value is text. JSON knows the difference between
"29"(text) and29(a number). - Size: CSV is smaller because column names appear only once. JSON repeats the keys in every record.
- Best for: CSV suits spreadsheets and bulk imports; JSON suits APIs, configuration files and JavaScript apps.
How to convert CSV to JSON step by step
- Read the first line and split it into column names:
name,email,age. - Read each following line and split it into values, respecting quoted fields (see the next section).
- Pair each value with the column name in the same position to build one object per row.
- Optionally convert numbers and true/false values so they are not stored as text.
- Wrap all the objects in square brackets to make a JSON array.
Example. This CSV:
name,email,age
Ayesha,ayesha@example.com,29
Bilal,bilal@example.com,34
becomes this JSON:
[{"name": "Ayesha", "email": "ayesha@example.com", "age": 29}, {"name": "Bilal", "email": "bilal@example.com", "age": 34}]
Quotes, commas and line breaks: the rules that matter
Most broken conversions come from values that contain the delimiter itself. RFC 4180 handles this with double quotes:
- A value that contains a comma, a double quote or a line break must be wrapped in double quotes:
"Karachi, Pakistan". - A double quote inside a quoted value is written twice:
"She said ""hi"""means She said “hi”. - A quoted value may span several lines, so you cannot always split a CSV file on line breaks.
- Spaces are part of the value.
Ayesha, 29gives" 29"with a leading space.
A good converter follows these rules automatically. Splitting each line on commas by hand will break as soon as an address or description contains a comma.
Semicolon and tab-separated files
In countries where the comma is the decimal separator, Excel often saves “CSV” files with semicolons, for example name;price and Pen;1,50. Tab-separated files (TSV) use a tab character instead. Choose the right delimiter before converting, or let the converter detect it from the first line.
How to convert JSON back to CSV
- Collect every key that appears in any object — these become the header row.
- Write one line per object, putting each value under its column and leaving a blank where a key is missing.
- Quote any value that contains the delimiter, a quote or a line break, and double the quotes inside it.
- Nested objects or arrays do not fit a flat table, so either flatten them into separate columns (such as
address.city) or store them as JSON text inside the cell.
Common mistakes to avoid
- Losing leading zeros: phone numbers and postal codes such as
007should stay text. Our converter only turns plain numbers without leading zeros into numbers. - Duplicate or empty headers: two columns called
namewould overwrite each other. Rename them, or let the converter add_2to duplicates. - Uneven rows: a row with fewer values than the header usually means an unquoted comma or line break earlier in the file.
- Encoding: save CSV files as UTF-8 so names such as Zoë or Urdu text are not garbled.
- Very large numbers: IDs longer than 15 digits can lose precision as JSON numbers, so keep them as text.
Opening and saving CSV files in Excel or Google Sheets
To export, use File → Save As → CSV UTF-8 in Excel, or File → Download → Comma-separated values in Google Sheets. To open a CSV without Excel changing long numbers or dates, use the Data → From Text/CSV import and set those columns to Text. After converting, check the JSON in the JSON Formatter, which highlights syntax errors and makes long files readable.
Frequently asked questions
Is CSV to JSON conversion safe for private data?
With our converter, yes — the file is read and converted in your browser and is not uploaded to a server.
Why are my numbers in quotes in the JSON?
CSV has no data types, so values stay as text unless the converter turns them into numbers. Turn on the option to convert numbers and true/false values.
Can CSV store nested data?
Not directly. Nested JSON has to be flattened into extra columns or stored as JSON text inside a single cell.
What does “uneven rows” mean?
Some rows have a different number of values than the header, usually because a value contains an unquoted comma or line break. Fix the quoting and convert again.
Keep reading: related guides
This guide is part of our free developer tools collection. Browse all free online tools or the full guide library.

