CSV Truncator
Truncate CSV files by rows, columns, or cell content. Upload or paste CSV data, configure limits, preview results, and download the truncated file.
About
Working with large CSV datasets often means handling files with thousands of rows and dozens of columns when only a subset is needed. Feeding an oversized file into a pipeline that expects 500 rows or 10 columns causes memory overflows, slow imports, and silent data corruption in downstream tools. This truncator parses your CSV with a finite-state machine that correctly handles RFC 4180 edge cases: quoted fields containing delimiters, escaped double-quotes, and multi-line cell values. You control three independent axes of truncation: row count (keep first n rows), column selection (keep or drop by index), and cell-level character limits. The tool processes everything client-side; no data leaves your browser.
Limitations: the parser assumes consistent column counts across rows. If your source file uses mixed delimiters or non-UTF-8 encoding without BOM, auto-detection may fail. In that case, set the delimiter and encoding manually. Files above 100 MB are rejected to prevent browser tab crashes. For datasets that large, consider a CLI tool like csvkit or awk.
Formulas
Truncation operates on three independent axes applied sequentially:
Row Truncation: Rout = min(Rtotal, nmax)
Column Truncation: Cout = { ci | i β Sselected }
Cell Truncation: cellout = cell[0 : min(len(cell), Lmax)]
Where Rtotal is the number of data rows (excluding header), nmax is the user-specified row limit, Sselected is the set of selected column indices, and Lmax is the maximum character count per cell. The parser uses a four-state FSM: FIELD_START β IN_UNQUOTED or IN_QUOTED β QUOTE_IN_QUOTED (for escaped quotes) β back to FIELD_START on delimiter or newline.
Reference Data
| Parameter | Default | Range / Options | Notes |
|---|---|---|---|
| Delimiter | , (comma) | , ; \t | custom | Auto-detected from first 5 lines |
| Quote Character | " | " ' | RFC 4180 standard uses double-quote |
| Max Rows | All | 1 - 1,000,000 | Excludes header row if βhas headerβ is on |
| Column Selection | All | Checkbox per column | Select which columns to keep |
| Cell Character Limit | None | 1 - 10,000 | Truncates individual cell content with ellipsis |
| Header Row | Yes | Yes / No | First row preserved separately from count |
| Encoding | UTF-8 | UTF-8, ISO-8859-1, Windows-1252 | BOM auto-detected |
| Line Ending | LF | LF, CRLF, CR | Output normalized to chosen format |
| Max File Size | - | 100 MB | Browser memory constraint |
| Empty Row Handling | Keep | Keep / Remove | Rows where all cells are empty |
| Whitespace Trimming | Off | On / Off | Trims leading/trailing spaces per cell |
| Output Format | CSV | CSV / TSV | Changes output delimiter accordingly |