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

FlagShortDescription
--delimiter-dField delimiter (default: ,)
--style-sBorder style: ascii, box, dos
--padding-pCell padding (default: 1)
--row-separatorInsert separator lines between data rows
--no-headerTreat first row as data
--right-columns-rOriginal column indices to right-align (1-based)
--max-width-wMax total table width (0 = auto-fit)
--transpose-tShow each record vertically
--columns-cColumn indices to show (1-based)
--max-sizeMax input file size in MiB (default: 64)

Examples

TSV input

1
printf 'a\tb\n1\t2\n' | pretty-csv -d $'\t'

Select columns

1
pretty-csv -c 1,3,5 data.csv

Right-align numeric columns

1
pretty-csv -r 2,4 ledger.csv

Row separators

1
pretty-csv --row-separator data.csv

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

1
pretty-csv -w 80 wide-data.csv
Last modified March 22, 2026: chore: bump to 0.5.0 (8c7d27e)