AAllMyToolsa pocketful of little tools
csv

CSV to JSON converter

DevNo. 17 / 84

Turn a CSV table into a JSON array of objects, with comma, semicolon or tab delimiters and proper handling of quoted fields.

a comma inside quotes is a comma with a permission slip.

work surface

Math, not advice — results are indicative.Read the disclaimer.

most-used utilities

Spreadsheet export

Turn a two-column sheet into a JSON array ready for a fixture file.

Quoted commas

Check that an address or a product description with commas stays in one piece.

Tab-separated data

Convert a copy-paste from a spreadsheet, which usually arrives with tabs, into JSON.

pro tips

Keep the header row short, unique and free of punctuation. Every key in the output comes straight from it.

If a column holds zip codes, phone numbers or account IDs, leave smart types off so the leading zeros survive.

Quote a field when it contains the delimiter, a quote or a line break. Quoting everything also works, but it makes the file harder to read.

what it does

Paste a table with a header row and the JSON appears as you type: one object per row, with the header cells as keys. Pick comma, semicolon or tab, and the parser follows the usual CSV rules instead of splitting on every comma it sees.

That means quoted fields can contain the delimiter, doubled quotes inside a quoted field become one quote, and a line break inside quotes stays inside the field rather than starting a new row. Values are kept exactly as written unless you switch on smart types.

Handy for turning a spreadsheet export into fixture data, for pasting a small table into a config file, for checking what an API will actually receive, or for proving to a colleague that the extra column was there all along.

Empty headers become column_1, column_2 and so on, repeated headers get a numeric suffix, and short rows are padded with empty strings. Smart types turns whole numbers, decimals, true, false and null into JSON values, but it leaves values with leading zeros alone — a zip code is not a number, whatever the spreadsheet thinks.

quick answers

Does it handle quoted fields with commas?

Yes. A field wrapped in double quotes can contain the delimiter, and a doubled quote inside it becomes a literal quote. Line breaks inside quotes stay in the value.

Why are my numbers coming out as strings?

By default every cell is kept exactly as written, which is safer for IDs and zip codes. Turn on smart types if you want whole numbers, decimals, true, false and null converted.

What happens to duplicate or missing headers?

Missing headers are named column_1, column_2 and so on, and duplicates get a suffix such as name_2. Short rows are filled with empty strings, so every object has the same keys.