CSV to Text Columns Converter
Convert CSV data into perfectly aligned text columns. Supports auto-delimiter detection, custom padding, alignment options, and RFC 4180 parsing.
About
Raw CSV output is unreadable without tooling. Misaligned columns cause data misinterpretation, especially in logs, reports, and terminal output where monospaced formatting is the only visual structure available. This converter parses CSV input using an RFC 4180-compliant state machine that correctly handles quoted fields containing commas, escaped double-quotes (""), and embedded newlines. It then calculates the maximum character width wmax for each column and pads every cell to produce perfectly aligned fixed-width text output.
The tool auto-detects the input delimiter by frequency analysis across the first 20 rows, scoring candidates (comma, tab, semicolon, pipe) by consistency. Output alignment is configurable per-column: left, right, or center. Note: alignment assumes a monospaced font. Proportional fonts will break visual alignment regardless of padding. For datasets exceeding 10,000 rows, consider splitting the file first - browser memory constraints apply.
Formulas
Column width calculation determines the padding required for alignment. For each column j in a dataset of m columns and n rows:
The padded output width for each cell includes a gutter g (user-configurable, default 2 spaces):
Where pad applies left, right, or center spacing. For center alignment, left padding = floor((wj − len(cell)) ÷ 2) and right padding absorbs the remainder.
Delimiter auto-detection scores each candidate d by computing the standard deviation σ of field counts per row. The delimiter with σ = 0 (perfectly consistent column count) and the highest median field count wins:
Where median_fields(d) is the median number of fields per row when split by delimiter d, and σ(d) is the standard deviation of field counts across sampled rows.
Reference Data
| Delimiter | Character | Common Use | Auto-Detect Priority | RFC Standard |
|---|---|---|---|---|
| Comma | , | General CSV (spreadsheets, exports) | 1 | RFC 4180 |
| Tab | \t | TSV files, database exports | 2 | IANA TSV |
| Semicolon | ; | European CSV (locale uses comma as decimal) | 3 | De facto |
| Pipe | | | Unix utilities, log files | 4 | De facto |
| Space | \s | Fixed-width legacy formats | 5 | None |
| Colon | : | /etc/passwd, config files | 6 | None |
| Output Padding Modes | ||||
| Left-align | Cell padded with trailing spaces: value··· | |||
| Right-align | Cell padded with leading spaces: ···value | |||
| Center-align | Cell padded equally on both sides: ·value·· | |||
| RFC 4180 Quoting Rules | ||||
| Rule 1 | Fields containing delimiters, quotes, or newlines must be enclosed in double-quotes | |||
| Rule 2 | Double-quote inside a quoted field is escaped as "" | |||
| Rule 3 | Leading/trailing whitespace inside quotes is preserved | |||
| Rule 4 | CRLF (\r\n) is the standard line ending; LF (\n) is accepted | |||
| Common CSV Encoding Issues | ||||
| BOM | UTF-8 BOM (0xEF 0xBB 0xBF) at file start causes phantom characters if not stripped | |||
| Encoding | Non-UTF-8 files (Windows-1252, ISO-8859-1) may produce garbled output | |||
| Trailing delimiter | Some exports append a trailing comma, creating an empty ghost column | |||
Frequently Asked Questions
block.