ComfyToolkit

Data Converter

Convert between JSON, YAML, TOML and CSV.

Input
1
Output
1

CSV to JSON Converter

Turn a spreadsheet export into a JSON array of objects, with the header row becoming the keys.

This page opens with CSV as the input and JSON as the output.

CSV is barely a format

There is no single specification, which is why exports disagree with each other. Delimiters vary by locale - semicolons are standard wherever the comma is the decimal separator. Line endings differ. Whether the first row is a header is a convention rather than a rule.

Quoted fields containing commas and newlines are parsed correctly here, which is the part naive splitting on commas gets wrong.

Everything arrives as a string

CSV carries no type information, so every value is text until something coerces it. Deciding what becomes a number, a boolean or a date is a judgement call, and doing it automatically is how a product code of 0012 becomes 12. Convert first, then coerce deliberately on the fields you know.

Watch the first cell

Exports frequently carry a byte-order mark at the start of the file. It is invisible, and it attaches itself to your first column name, producing a key that looks correct and does not match. If a lookup on the first column is mysteriously failing, that is usually why.

Duplicate and empty headers

A spreadsheet export frequently has blank trailing columns or two columns sharing a name. Both produce awkward JSON - a key that is the empty string, or one column silently overwriting another.

Cleaning the header row before converting is the single highest-value thing you can do to a CSV, and it takes seconds.

Open the full Data Converter