Turning header-plus-rows CSV into an array of objects
'name,role' followed by 'Ada,eng' and 'Lin,design' converts into a JSON array of two objects: {"name": "Ada", "role": "eng"} and {"name": "Lin", "role": "design"} -- the header row becomes each object's keys, and each subsequent row becomes one object with values matched positionally to those keys.
This is the reverse and complementary operation to converting JSON back to CSV -- together, the pair lets data move freely between spreadsheet-friendly CSV and API/code-friendly JSON without manual reformatting.
The first row is always treated as the header/key row, not as data -- a CSV file without a header row would have its first data row incorrectly consumed as column names rather than as an actual record.
What this parser handles, and its stated limit
Supports quoted commas. Multi-line cells are not handled. A value containing a comma, properly wrapped in quotes per standard CSV convention (like "Smith, John"), is correctly recognized as one field rather than being incorrectly split into two -- a common source of broken CSV parsing that this converter specifically handles.
Cell values that themselves contain a line break (a multi-line address or note inside one CSV cell, again properly quoted per the CSV spec) are not supported here -- this parser expects one CSV row to correspond to exactly one line of input text.
Every data row is expected to have the same number of fields as the header row -- a row with more or fewer commas than the header would produce a JSON object with mismatched or missing keys.
Related data-format conversion tools
To convert the resulting JSON array into a formatted HTML table instead, the HTML Table from CSV Generator handles that display format directly from CSV.
For turning this same CSV data into SQL INSERT statements instead of JSON, the CSV to SQL Insert Generator is the database-focused conversion.
Frequently Asked Questions (FAQ)
How does the converter know which CSV column becomes which JSON key?
The first row of the CSV is always treated as the header, defining the key names in order. Every subsequent row's values are matched positionally to those header keys to build each JSON object.
Does this handle a value that contains a comma?
Supports quoted commas. Multi-line cells are not handled. Yes, as long as it's properly quoted per standard CSV convention (like "Smith, John") -- the quotes tell the parser to treat the comma inside as part of the value, not as a field separator.
Does this handle a cell with a line break inside it?
No. Supports quoted commas. Multi-line cells are not handled. This parser expects exactly one line of text per CSV row. A quoted multi-line cell (legal per the CSV specification but requiring more complex line-continuation logic) isn't supported here.
What happens if a data row has a different number of fields than the header?
It would produce a JSON object with mismatched keys and values -- extra fields beyond the header count may be dropped, or missing fields may leave some keys without corresponding values, depending on how the row aligns with the header.
Is a header row required for this converter to work correctly?
Yes. The first row is always interpreted as column names, not as data. A CSV file without a proper header row would have its first actual data row incorrectly consumed as the key names instead of being converted into a record.