pretty-csv
Pretty-print CSV files as aligned tables
pretty-csv renders CSV (or TSV) files as aligned, bordered tables in the terminal.
- Auto-fits table width to the terminal (truncates with
…). - Three border styles:
ascii,box,dos. - Transpose mode: show each record as a vertical key-value block.
- Column selection: display only specific columns.
- Optional row separators between data rows.
- Right-align selected original columns (useful for numeric CSV fields).
- For standard comma-separated CSV input, parsing now fully implements RFC 4180.
- Supports quoted fields, including delimiters inside quotes.
- Supports embedded CRLF inside quoted fields.
- Unescapes doubled quotes in quoted fields.
- Rejects malformed quoted fields and rows with inconsistent column counts.
Demo
$ printf 'Name,Age,City\nAlice,30,Beijing\nBob,25,New York\nCharlie,35,London\n' | pretty-csv ┌─────────┬─────┬──────────┐ │ Name │ Age │ City │ ├─────────┼─────┼──────────┤ │ Alice │ 30 │ Beijing │ │ Bob │ 25 │ New York │ │ Charlie │ 35 │ London │ └─────────┴─────┴──────────┘
Options
| Flag | Short | Description |
|---|---|---|
--delimiter | -d | Field delimiter (default: ,) |
--style | -s | Border style: ascii, box, dos |
--padding | -p | Cell padding (default: 1) |
--row-separator | Insert separator lines between data rows | |
--no-header | Treat first row as data | |
--right-columns | -r | Original column indices to right-align (1-based) |
--max-width | -w | Max total table width (0 = auto-fit) |
--transpose | -t | Show each record vertically |
--columns | -c | Column indices to show (1-based) |
--max-size | Max input file size in MiB (default: 64) |
Examples
TSV input
| |
Select columns
| |
Right-align numeric columns
| |
Row separators
| |
Transpose mode
$ printf 'Name,Age,City\nAlice,30,Beijing\nBob,25,New York\n' | pretty-csv -t ┌──────┬─────────┐ │ Name │ Alice │ │ Age │ 30 │ │ City │ Beijing │ └──────┴─────────┘ ┌──────┬──────────┐ │ Name │ Bob │ │ Age │ 25 │ │ City │ New York │ └──────┴──────────┘
Limit table width
| |