How to Convert CSV to JSON
Convert CSV rows into JSON objects or arrays while handling headers, quoted commas, and inconsistent columns.
This guide is part of our Productivity library. It is written for readers who want practical steps, plain-language explanations, and automation ideas that keep human review in the right places.
Understand the two data shapes
CSV represents a table as rows and fields, usually separated by commas. JSON can represent the same information as an array of objects with named properties or as an array of row arrays.
When the first CSV row contains unique column names, using it as headers produces readable objects. Without headers, preserving every row as an array may be the more accurate choice.
Step 1: inspect and clean the CSV
Check the delimiter, header row, blank lines, and number of fields in each row. Make sure every header has a useful name and note duplicate headings before conversion.
A comma inside a field must be enclosed in double quotes. A double quote inside a quoted field is commonly represented by two consecutive double quotes. Do not remove these markers without understanding the data.
Step 2: choose how headers should work
Enable the first-row-as-headers option when the first row contains names such as customer, plan, and status. Each later row can then become an object using those names as keys.
Disable the option when the first row is actual data or when another system expects arrays. The correct choice depends on the meaning of the source, not simply on its first line.
Step 3: convert and validate
Paste the source into the CSV to JSON Converter and run the conversion. If it reports inconsistent column counts or an unclosed quote, correct the source instead of guessing at missing values in the output.
Review several early, middle, and final records. Check fields containing commas, quotes, line breaks, leading zeros, and non-English characters because these often reveal parsing or encoding assumptions.
Conversion example
A CSV with the headers name, department, and hours can become a JSON array in which each employee row is an object. The header values become property names and the original cells become string values.
Keeping values as strings protects identifiers such as 00125 from losing leading zeros. Convert types later only when you have explicit rules for numbers, dates, Booleans, and missing values.
Common mistakes
Common mistakes include splitting every line on commas without respecting quotes, treating a data row as headers, accepting uneven rows silently, and assuming every numeric-looking value should become a number.
Do not paste production exports containing personal or confidential data into tools without checking how they process information. Use a small, anonymized sample to confirm the workflow first.
What to do after conversion
Format and validate the JSON, then compare record counts with the CSV source. Confirm the property names match what the receiving application expects.
Test the result in a development or staging workflow before importing it into a live system. Keep the original CSV so the conversion can be reproduced if mapping rules change.
Frequently Asked Questions
Should the first CSV row always become JSON keys?
Only when it contains column names. Otherwise, convert all rows to arrays or provide headers separately.
Why do values remain strings?
Preserving strings avoids silently changing identifiers, leading zeros, dates, and other ambiguous values.
Can a CSV field contain a comma?
Yes. It should be correctly enclosed in double quotes so the comma is treated as content rather than a separator.
Related articles
How to Format and Validate JSON Online
Format compact JSON, validate its syntax, understand common errors, and copy a clean result for development work.
How to Document Your Automation Workflows
Document automation workflows with purpose, trigger, connected tools, owner, test data, troubleshooting notes, and rollback steps.