Skip to content

izag8216/tblfmt

Repository files navigation

tblfmt

CI Python 3.9+ License Zero Dependencies

日本語


tblfmt is a zero-dependency Python CLI tool that reads tabular data from files or stdin and renders it with beautiful Unicode box drawing characters. Pipe-friendly, format-agnostic, and style-rich.

Features

  • Zero dependencies -- Uses only Python standard library
  • Pipe-friendly -- cat data.csv | tblfmt
  • Multiple input formats -- CSV, TSV, JSON (array-of-objects), Markdown tables (auto-detected)
  • Six border styles -- light, heavy, double, rounded, dashed, ascii
  • Flexible alignment -- Global or per-column left/center/right alignment
  • Multiple output formats -- terminal, markdown, csv, tsv, json
  • CJK-aware -- Correctly calculates display width for East Asian characters

Installation

pip install tblfmt

Or install from source:

git clone https://github.com/izag8216/tblfmt.git
cd tblfmt
pip install -e .

Quick Start

# Render a CSV file with default light Unicode borders
tblfmt data.csv

# Pipe from stdin
cat data.csv | tblfmt --style heavy

# Convert JSON to a formatted table
tblfmt --format json data.json

# Output as Markdown
tblfmt --output markdown data.csv

# Right-align numeric columns
tblfmt --align-col "3:right,4:right" data.csv

Border Styles

Style Preview
light (default) ┌─┬─┐ │ ├─┼─┤ └─┴─┘
heavy ┏━┳━┓ ┃ ┣━╋━┫ ┗━┻━┛
double ╔═╦═╗ ║ ╠═╬═╣ ╚═╩═╝
rounded ╭─┬─╮ │ ├─┼─┤ ╰─┴─╯
dashed ┌╌┬╌┐ ╎ ├╌┼╌┤ └╌┴╌┘
ascii +-+ | +-+-+ +-+-+
# Preview all styles
tblfmt --list-styles

CLI Reference

tblfmt [file] [options]

Options:
  --style {light,heavy,double,rounded,dashed,ascii}
                        Border style (default: light)
  --output {terminal,markdown,csv,tsv,json}
                        Output format (default: terminal)
  --format {auto,csv,tsv,json,markdown}
                        Input format (default: auto-detect)
  --no-header           Treat first row as data, not header
  --align {left,center,right}
                        Global cell alignment (default: left)
  --align-col COL:ALIGN,...
                        Per-column alignment, e.g. "1:right,2:center"
  --padding N           Cell padding spaces (default: 1)
  --list-styles         Show all styles with preview
  --version             Show version
  -h, --help            Show help

Examples

Convert formats

# CSV to Markdown
tblfmt --output markdown data.csv

# Markdown to CSV
tblfmt --format markdown --output csv table.md

# JSON to TSV
tblfmt --format json --output tsv data.json

Alignment control

# Center all cells
tblfmt --align center data.csv

# Mixed alignment: left col 1, center col 2, right col 3
tblfmt --align-col "1:left,2:center,3:right" data.csv

Shell integration

# Add to .bashrc or .zshrc
alias tf='tblfmt'
alias tfm='tblfmt --output markdown'

# Use with other CLI tools
ps aux | head -5 | tblfmt --format tsv --style heavy

Documentation

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

MIT License -- see LICENSE for details.

About

Terminal Table Formatter with Unicode Box Drawing -- zero-dependency Python CLI

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages