CSV to ASCII Table Converter
Convert CSV data to formatted ASCII tables online. Supports MySQL, Markdown, Unicode box-drawing, and 7 border styles with instant preview.
About
Misaligned columns in plain-text data cause parsing failures, misread reports, and broken documentation. This converter transforms raw CSV input into precisely formatted ASCII tables using character-level column-width analysis. Each column width wj is computed as the maximum string length across all n rows for column j, guaranteeing uniform alignment regardless of data variance. The parser implements a finite-state machine compliant with RFC 4180, correctly handling quoted fields containing commas, newlines, and escaped double-quotes (""). Seven output styles are supported: MySQL grid, PostgreSQL, Markdown, Unicode box-drawing (U+2500 block), reStructuredText, compact, and simple.
The tool approximates output width as W = ∑ wj + 3k + 1, where k is the column count and 3 accounts for padding and separator characters per column. Limitations: tab-separated values require selecting the tab delimiter. Fields exceeding 500 characters are truncated to prevent terminal overflow. Pro tip: Markdown style output pastes directly into GitHub README files and Jira tickets without modification.
Formulas
Column width for each column j is determined by scanning all rows:
Total table width including borders and padding:
Where wj = computed width of column j, k = total number of columns, n = total number of rows, 2 = left and right padding per cell, k + 1 = number of vertical border characters. The CSV parser operates as a deterministic finite automaton with 4 states:
Transitions: at FIELD_START, a " character transitions to QUOTED; any other character transitions to UNQUOTED. Inside QUOTED, a " transitions to QUOTE_ESCAPE, where a second " emits a literal quote and returns to QUOTED, while any other character finalizes the field.
Reference Data
| Style | Corner | Horizontal | Vertical | Cross | Best Use |
|---|---|---|---|---|---|
| MySQL | + | - | | | + | Database CLI output |
| PostgreSQL | + | - | | | + | psql-style reports |
| Markdown | | | - | | | | | GitHub, Jira, docs |
| Unicode | ┌┐└┘ | ─ | │ | ┼ | Terminal dashboards |
| reStructuredText | + | = / - | | | + | Sphinx documentation |
| Simple | (none) | - | (space) | (none) | Quick readable output |
| Compact | (none) | (none) | (space) | (none) | Minimal space usage |
| RFC 4180 CSV Parsing Rules | |||||
| Rule 1 | Records delimited by CRLF, LF, or CR | ||||
| Rule 2 | Optional header row (first row treated as header by default) | ||||
| Rule 3 | Fields separated by comma (configurable delimiter) | ||||
| Rule 4 | Fields containing delimiters, quotes, or newlines must be enclosed in double quotes | ||||
| Rule 5 | Double quotes inside quoted fields escaped as "" | ||||
| Common Delimiter Characters | |||||
| Comma | , | Standard CSV (RFC 4180) | |||
| Tab | \t | TSV files, spreadsheet exports | |||
| Semicolon | ; | European locale CSV | |||
| Pipe | | | Database dumps, log files | |||
| Colon | : | /etc/passwd, config files | |||
| Space | (whitespace) | Fixed-width-like data | |||