CSV to Text Converter
Convert CSV files to formatted plain text with aligned columns, Markdown tables, key-value pairs, and custom templates. RFC 4180 compliant parser.
About
CSV parsing fails silently. A misplaced comma inside an unquoted field shifts every column to the right, corrupting downstream data pipelines and reports. This converter implements a full RFC 4180-compliant finite state machine parser that correctly handles quoted fields containing commas, embedded newlines (CRLF inside double quotes), and escaped quote characters ("" sequences). It does not split on commas naively. The parser transitions through four discrete states - FIELD_START, UNQUOTED, QUOTED, and QUOTE_IN_QUOTED - to produce a correct two-dimensional array regardless of field content.
Output formats include fixed-width aligned tables (column width w computed as max(cell lengths) per column), Markdown-compatible tables with pipe delimiters, tab-separated values for spreadsheet pasting, and key-value pair layouts for configuration files. The tool approximates real conversion assuming UTF-8 input and monospaced character widths. CJK or emoji characters will misalign in fixed-width modes because their display width is 2 columns, not 1.
Formulas
The CSV parser operates as a finite state machine with four states. Each character c at position i triggers a transition:
For aligned table output, each column width wj is computed across all m rows:
Where wj is the display width of column j, len returns the string length of the cell content, and padding is the user-configured extra spacing (default 2). Each cell is then padded using padEnd(wj) for left alignment or padStart(wj) for right alignment.
Reference Data
| Output Format | Separator | Alignment | Use Case | Header Row | Border Characters |
|---|---|---|---|---|---|
| Plain Columns | Space(s) | Left | Quick visual inspection | Optional | None |
| Aligned Table | Pipe | | Left-padded | Terminal / log output | Yes, with separator line | + - | |
| Markdown Table | Pipe | | Left | Documentation, GitHub, wikis | Required (first row) | | --- |
| Tab-Separated (TSV) | Tab \t | None | Spreadsheet paste, data exchange | Preserved | None |
| Key-Value Pairs | Colon : | Right-aligned keys | Config files, record display | Used as keys | None |
| Custom Template | User-defined | User-defined | Custom report generation | Optional | User-defined |
| JSON Lines | N/A | N/A | Streaming data, log ingestion | Used as keys | { } |
| HTML Table | N/A | N/A | Web embedding, emails | Uses <th> | HTML tags |
| Fixed Width | None (padding) | Left or Right | Mainframe, legacy systems | Optional | None |
| SQL INSERT | Comma | N/A | Database seeding | Used as column names | ( ) |
| XML Records | N/A | N/A | Enterprise data exchange | Used as tag names | < > |
| YAML | Colon : | Indented | Configuration, DevOps | Used as keys | - |