Client-side data tool
CSV to JSON Converter — Paste or Upload CSV/TSV and Download JSON
Paste CSV or TSV, preview the parsed rows, and convert to JSON without uploading data to a server.
Preview area
One-line tool description
Convert CSV or TSV text/files to clean JSON in your browser — paste data or upload a .csv, choose delimiter and header options, preview results, then download or copy the JSON. Client-side only; no files are uploaded to a server.
3-step quick use
- Paste your CSV text or choose a .csv/.tsv file to upload.
- Confirm delimiter (comma, tab, semicolon) and header settings; preview the first rows.
- Export: download a .json file or copy the JSON to clipboard.
How it works (principles and formulas — sources cited)
- File input and size: the tool reads files in the browser (FileReader.readAsText). This loads the file into memory; for practical stability the project treats ~10 MB as a recommended safety limit (MDN FileReader.readAsText warning). See MDN FileReader: https://developer.mozilla.org/ (FileReader.readAsText).
- Delimiter detection (autodetect): if you select "autodetect", the parser tests candidate delimiters [",", ";", "\t", "|"] across the first K = 20 lines (default). For each delimiter it computes the mode and variance of column counts; the delimiter with highest modal column count and lowest variance is chosen. (Heuristic used by common implementations; see PapaParse docs and the project pre-research.)
- Quoting and line breaks: parsing follows RFC 4180-style rules: fields may be double-quoted; inside quotes commas and CR/LF are allowed; a literal double-quote is escaped by doubling (""). The parser tokenizes character-by-character maintaining an inQuotes state so delimiters and newlines inside quotes are not treated as separators. Source: RFC 4180.
- Headers and column schema: users can set header row count (>=0). If header_rows = 1 (default), first row yields keys. If header_rows = 0, generated keys col1..colN are used. For multiple header rows the implementation will join header rows with ' / ' to create composite column names (documented behavior).
- Mismatched columns policy (validation): after parsing, determine expectedCols = header.length (if header present) or maxCols across all rows. Default mode = Lenient:
- If a row has fewer fields than expected -> pad missing fields with null and emit a warning.
- If a row has more fields -> create additional columns named _extra1, _extra2... and emit a warning.
- Output modes:
- Array-of-objects: each CSV row becomes an object keyed by column names.
- Nested/grouped JSON (one-level grouping): specify a group-by column; the tool creates either a map { key: [items] } or an array-of-groups [ {"key":...,"items":[...]} ]. When grouping, the group-by column may be omitted from child objects (configurable).
- Preview: shows first N = 10 rows by default (configurable). Delimiter autodetect uses K >= N (default K = 20) to ensure robust detection before preview.
- Empty values and type coercion: by default values are strings. Options: convert empty strings to null, and opt-in type coercion (numbers, booleans) using deterministic regex rules (e.g. /^-?\d+(\.\d+)?$/ for numbers; case-insensitive 'true'/'false' for booleans).
- Download: JSON is serialized and provided as a Blob (application/json) so the browser can download originalfilename.json or data.json via URL.createObjectURL.
FAQ
Will the tool handle fields that contain commas, quotes, or newlines?
Yes — the parser follows RFC 4180 quoting rules: double-quoted fields may contain commas and CR/LF, and quotes inside fields are escaped by doubling (""). If your CSV follows RFC 4180 quoting, those values will parse correctly. (RFC 4180)
What delimiters are supported and how does autodetect work?
Supported delimiters: comma (,), tab (\t), semicolon (;). Autodetect tests multiple delimiters over the first K = 20 lines and chooses the one with the most consistent column counts (highest mode, lowest variance). You can override the selection manually.
My rows have different numbers of columns — what happens?
Default (Lenient): rows with missing fields are padded with null; rows with extra fields create additional columns named _extra1, _extra2... and the tool shows validation warnings listing affected row numbers. You can choose Strict mode to abort on mismatches.
Is my file uploaded to a server?
No. The conversion runs entirely in your browser (FileReader). The tool reads the file locally and does not send file contents to any server. Note: readAsText loads the whole file into memory — for practical stability the tool recommends files around or below ~10 MB. (MDN FileReader.readAsText)
Can I produce nested JSON grouped by a column?
Yes. Select a group-by column to generate either a key→array map or an ordered array-of-groups. Grouping is one-level (rows grouped by the chosen key); the group column can be retained or removed from child objects depending on your preference.
Will empty strings be converted to null or will numeric text be converted to numbers?
By default values are left as strings. You can toggle "convert empty to null". Automatic type coercion (numbers/booleans) is opt-in and follows deterministic rules (numeric regex and case-insensitive booleans) to avoid accidental conversions.
How many rows are previewed and can I change it?
Default preview = 10 rows (configurable). Autodetect uses K = 20 lines to select delimiter reliably before showing a preview.
What if the file is very large or causes the browser to hang?
FileReader.readAsText loads the full file into memory and may crash or hang the tab with very large files. The tool recommends staying near/under ~10 MB. For larger datasets a chunked/streaming approach is safer (future enhancement).