How to Convert CSV to JSON
Paste nonempty CSV text, select its delimiter, choose the correct header setting, and convert it to JSON. Then inspect rows with unusual field counts because they can use a different output shape.
Prepare the CSV for conversion
CSV to JSON conversion helps when tabular text needs to be handled as structured data. This converter accepts CSV content as text and returns a JSON representation. Before starting, identify the separator used between fields and decide whether the first row contains property names. The comma is the default delimiter, semicolons are supported, and the declared default JSON indentation is 2 spaces.
A quick inspection of the source prevents avoidable shape changes. Look at the first row, count the fields in later rows, and note whether the text uses commas or semicolons. Header handling is enabled by default, so the first row is treated as headers unless you turn that option off. A source without headers needs the different setting before conversion.
Convert the CSV text
-
Prepare the CSV content as text. Include the first row when it contains the field names you want to use as JSON properties. Do not submit an empty or whitespace-only value, because that input is rejected rather than converted.
-
Enter or paste the CSV text into the input area.
-
Select the delimiter that matches the source. Keep the comma option for comma-separated content, or choose the semicolon option for semicolon-delimited content.
-
Check header handling. Leave it enabled when the first row supplies names for the JSON properties. Disable it when the first row is data and should be processed as a row instead of as headers.
-
Set the JSON indentation value. The declared default is 2, but you can adjust the setting for the preferred display format.
-
Start the conversion and inspect the returned JSON output. If CSV parsing raises an exception, the conversion ends unsuccessfully and does not return JSON output.
When headers are enabled, compare each row's field count with the header count. A matching row becomes a key-value record, and surrounding whitespace is removed from its header and cell text. A row with a different field count follows a row-value representation instead of being forced into the header-based structure.
Read and check the JSON result
With header handling enabled, a row that has the same number of fields as the first row is represented as a record whose keys come from that first row. For example, headers named name,department can provide the corresponding property names for later matching rows. Surrounding spaces in header and cell text are stripped, so inspect the resulting values if spacing carries meaning in your source.
Turning header handling off changes the interpretation of the first row: it is processed as row data rather than supplying property names. This option is useful when the source begins with values, but the resulting JSON should not be read as a collection of header-keyed records. Irregular rows also deserve separate inspection because their field count determines a different row-value shape.
A failed outcome means the supplied text was not converted into JSON output. Recheck the separator, the header choice, and the CSV structure before trying again. The indentation setting changes the presentation of JSON, while delimiter and header choices affect how the source is represented.
Worked example
A team member has a small comma-separated staff list with a header row and needs a structured JSON representation.
Paste the three CSV lines name,department, Maya,Support, and Leo,Sales; keep the comma delimiter and header handling enabled, then start the conversion.
The result has a JSON array containing records with name and department properties, formatted with the selected indentation.
Limitations
- Empty or whitespace-only input is rejected, and a parsing exception produces an unsuccessful outcome instead of JSON output.
Common errors
- If the selected delimiter does not match the source, or a data row is treated as headers, the conversion can end unsuccessfully or produce an unexpected structure; select the matching separator and disable header handling when the first row contains data.
FAQ
Can I convert semicolon-delimited CSV to JSON?
Yes, when the fields are separated by semicolons, choose the semicolon delimiter before starting the conversion instead of leaving the default comma selected.
What happens when a CSV row has a different number of fields?
When header handling is enabled, a row matching the first row's field count becomes a key-value record, while a row with a different count is retained as row values.
Can I convert an empty CSV input?
No. Empty or whitespace-only CSV text is rejected, so enter content before starting the conversion.