A powerful, scriptable CLI tool for formatting CSV data into beautiful tables. Built with Rust for speed and reliability.
- 📥 Flexible Input: Read from files or stdin
- 🔍 Auto-Detection: Automatically detects delimiters and headers
- 🎨 Multiple Styles: 6 built-in table styles (ASCII, Unicode, Markdown, and more)
- ⚙️ Highly Configurable: Extensive options for alignment, borders, colors, and layout
- 🎯 Conditional Formatting: Automatically color and style cells based on their values
- 🚀 Fast & Efficient: Written in Rust for optimal performance
- 📝 Script-Friendly: Designed for use in pipelines and automation
# Clone or navigate to the project directory
git clone <repository-url>
cd tbl
# Build and install
cargo install --path .
# Or just build
cargo build --release
# Binary will be at: target/release/tblGenerate shell completions for your shell:
# Bash
tbl completions bash > ~/.local/share/bash-completion/completions/tbl
source ~/.bashrc
# Zsh
tbl completions zsh > ~/.zsh/completions/_tbl
# Add to .zshrc: fpath=(~/.zsh/completions $fpath)
source ~/.zshrc
# Fish
tbl completions fish > ~/.config/fish/completions/tbl.fish
source ~/.config/fish/config.fish
# PowerShell
tbl completions powershell > tbl.ps1
. ./tbl.ps1Completions provide tab-completion for:
- All flag names (
--header-color,--style, etc.) - Enum values (styles, colors, alignments)
- File paths
# Basic usage with pipe
echo -e "name,age,city\nAlice,30,NYC\nBob,25,LA" | tbl
# From a file
tbl data.csv
# With custom style
cat data.csv | tbl --style ascii
# Right-aligned with markdown output
tbl data.csv --style markdown --align right💡 Try it yourself! The
examples/directory contains sample data files. See Real-World Examples for comprehensive demonstrations of all features.
tbl [OPTIONS] [FILE]
[FILE]- Input CSV file (use-for stdin, or omit for stdin by default)
| Option | Description |
|---|---|
--csv |
Force CSV format (comma-separated, default) |
-d, --delimiter <CHAR> |
Use custom delimiter character |
--header |
Force first row as headers |
--no-header |
Force first row as data (no headers) |
--no-trim |
Don't trim whitespace from cells |
Note: By default,
tblauto-detects delimiters and headers intelligently.
| Option | Description |
|---|---|
-s, --style <STYLE> |
Table style preset (default: unicode) |
Available Styles:
ascii- ASCII characters only (+-|)unicode- Unicode box drawing (default)markdown- Markdown-compatible tablesrounded- Rounded corners with Unicodesharp- Sharp ASCII styledots- Dotted borders
| Option | Description |
|---|---|
-w, --max-width <WIDTH> |
Maximum table width in characters |
--padding <NUM> |
Horizontal padding (default: 1) |
| Option | Description |
|---|---|
-a, --align <ALIGN> |
Column alignment: left, center, right (default: left) |
--header-align <ALIGN> |
Header alignment (default: same as columns) |
| Option | Description |
|---|---|
--no-outer-border |
Remove outer borders |
--no-column-border |
Remove column separators |
--no-header-separator |
Remove header separator line |
| Option | Description |
|---|---|
--header-color <COLOR> |
Header text color |
--header-bg-color <COLOR> |
Header background color |
--alt-row-bg <C1>,<C2> |
Alternating row backgrounds (zebra striping) |
Available Colors: black, red, green, yellow, blue, magenta, cyan, white, and bright-* variants
| Option | Description |
|---|---|
--header-bold |
Make header text bold |
--header-underline |
Make header text underlined |
All column options support range syntax (2-4) and multi-target syntax (2,3,5).
| Option | Description |
|---|---|
--column-align <COLS>:<ALIGN> |
Set alignment for columns |
--column-color <COLS>:<COLOR> |
Set text color for columns |
--column-bg <COLS>:<COLOR> |
Set background color for columns |
--column-bold <COLS> |
Make columns bold |
Examples:
--column-align 2:right(single column)--column-align 2-4:right(range: columns 2, 3, 4)--column-color 2,3,5:blue(multiple: columns 2, 3, and 5)
All row options support range syntax (2-4) and multi-target syntax (1,3,5).
Row numbers are 1-based (first data row = 1, not counting headers).
| Option | Description |
|---|---|
--row-color <ROWS>:<COLOR> |
Set text color for rows |
--row-bg <ROWS>:<COLOR> |
Set background color for rows |
--row-bold <ROWS> |
Make rows bold |
Examples:
--row-color 1:red(highlight first row)--row-bg 2-4:bright-black(shade rows 2-4)
Cell options support list syntax (1,1,2,2) and range syntax (1,1-3,3).
Cell coordinates are COL,ROW pairs (both 1-based).
| Option | Description |
|---|---|
--cell-color <COORDS>:<COLOR> |
Set text color for specific cells |
--cell-bg <COORDS>:<COLOR> |
Set background color for cells |
--cell-bold <COORDS> |
Make cells bold |
Examples:
--cell-color 1,1:red(single cell at column 1, row 1)--cell-bg 1,1-3,3:yellow(rectangular range from 1,1 to 3,3)--cell-bold 1,1,2,2,3,3(list of cells)
Enable row headers to treat the first column as row labels (like a spreadsheet).
| Option | Description |
|---|---|
--row-headers |
Enable row header mode |
--row-header-color <COLOR> |
Text color for row headers |
--row-header-bg-color <COLOR> |
Background color for row headers |
--row-header-bold |
Make row headers bold |
--row-header-underline |
Underline row headers |
--row-header-align <ALIGN> |
Alignment for row headers |
When both column headers (first row) and row headers (first column) are present, the top-left cell is the "corner cell".
| Option | Description |
|---|---|
--corner-text <TEXT> |
Custom text for corner cell |
--corner-color <COLOR> |
Text color for corner cell |
--corner-bg-color <COLOR> |
Background color for corner cell |
echo -e "name,age,city\nAlice,30,NYC\nBob,25,LA" | tbl┌───────┬─────┬──────┐
│ name ┆ age ┆ city │
╞═══════╪═════╪══════╡
│ Alice ┆ 30 ┆ NYC │
├╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌┤
│ Bob ┆ 25 ┆ LA │
└───────┴─────┴──────┘
tbl data.csv --style ascii+-------+-----+------+
| name | age | city |
+====================+
| Alice | 30 | NYC |
+-------+-----+------+
| Bob | 25 | LA |
+-------+-----+------+
tbl data.csv --style markdownPerfect for documentation:
┌───────────────────┐
│ name age city │
╞═══════════════════╡
│ Alice 30 NYC │
│ Bob 25 LA │
└───────────────────┘
Auto-detection works seamlessly:
echo -e "fruit|color|taste\napple|red|sweet" | tbl┌───────┬───────┬───────┐
│ fruit ┆ color ┆ taste │
╞═══════╪═══════╪═══════╡
│ apple ┆ red ┆ sweet │
└───────┴───────┴───────┘
cat prices.csv | tbl --align right┌─────────┬───────┬─────┐
│ Product ┆ Price ┆ Qty │
╞═════════╪═══════╪═════╡
│ Apple ┆ 1.50 ┆ 10 │
├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌┤
│ Banana ┆ 0.75 ┆ 25 │
└─────────┴───────┴─────┘
echo -e "1,2,3\n4,5,6" | tbl --no-header┌───┬───┬───┐
│ 1 ┆ 2 ┆ 3 │
├╌╌╌┼╌╌╌┼╌╌╌┤
│ 4 ┆ 5 ┆ 6 │
└───┴───┴───┘
tbl data.txt -d ';' --style rounded# Bold headers with background
tbl data.csv --header-bold --header-bg-color black --header-color cyan# Right-align numeric columns
tbl financial.csv --column-align 2:right --column-align 3:right --column-align 4:right# Subtle alternating backgrounds for readability
tbl data.csv --alt-row-bg white,bright-black# Professional report styling
tbl report.csv \
--header-bold \
--header-bg-color black \
--header-color cyan \
--column-align 1:left \
--column-align 2:right \
--column-align 3:right \
--alt-row-bg white,bright-black \
--style rounded# Right-align all numeric columns at once
tbl data.csv --column-align 2-5:right --column-bold 2-5
# Color-code multiple columns
tbl sales.csv \
--column-color 2:green \
--column-color 3-4:yellow \
--column-bg 5:bright-black# Highlight header row and first data row
echo -e "Name,Score\nAlice,95\nBob,78\nCarol,88" | tbl \
--row-color 1:bright-blue \
--row-bold 1
# Shade alternate sections
tbl report.csv --row-bg 1-3:white --row-bg 4-6:bright-black# Highlight specific cells
tbl data.csv \
--cell-color 1,1:red \
--cell-bg 2,2-4,4:yellow \
--cell-bold 1,1
# Draw attention to a range
tbl matrix.csv --cell-color 1,1-3,3:bright-green --cell-bold 1,1-3,3# Grade book with student names as row headers
echo -e "Student,Math,Science,English\nAlice,95,88,92\nBob,78,92,85\nCarol,88,95,90" | tbl \
--row-headers \
--row-header-bold \
--header-bg-color blue \
--row-header-bg-color green \
--column-align 2-4:right
# Financial report with labeled rows
tbl quarterly.csv \
--row-headers \
--corner-text "Q4 2024" \
--corner-color bright-magenta \
--row-header-align right# Global zebra + column colors + cell highlights
tbl data.csv \
--alt-row-bg white,bright-black \
--column-color 2:green \
--cell-color 1,1:bright-red \
--cell-bg 3,3:yellowStyling Priority (highest to lowest):
- Cell-specific (
--cell-*) - Row/Column-specific (
--row-*,--column-*) - Row headers (
--row-header-*) - Global defaults (
--align,--header-*) - Zebra striping (
--alt-row-bg)
echo -e "Product,Q1,Q2,Q3,Q4,Total\nLaptops,120,135,142,158,555\nMice,380,425,410,445,1660\nKeyboards,210,195,220,235,860" | tbl \
--row-headers \
--corner-text "2024" \
--corner-color bright-cyan \
--corner-bg-color black \
--header-bold \
--header-bg-color blue \
--row-header-bold \
--row-header-bg-color green \
--column-align 2-6:right \
--column-bold 6 \
--cell-color 6,1:bright-yellow \
--cell-color 6,2:bright-yellow \
--cell-color 6,3:bright-yellow \
--alt-row-bg white,bright-black \
--style roundedOutput concept (colors shown as text):
╭─────────────┬─────┬─────┬─────┬─────┬────────╮
│ [2024] ┆ Q1 ┆ Q2 ┆ Q3 ┆ Q4 ┆ Total │ ← Blue bg, bold
╞═════════════╪═════╪═════╪═════╪═════╪════════╡
│ [Laptops] ┆ 120 ┆ 135 ┆ 142 ┆ 158 ┆ [555] │ ← Green bg (row header), white bg (zebra)
├╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
│ [Mice] ┆ 380 ┆ 425 ┆ 410 ┆ 445 ┆ [1660] │ ← Bright-black bg (zebra)
├╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
│ [Keyboards] ┆ 210 ┆ 195 ┆ 220 ┆ 235 ┆ [860] │ ← White bg (zebra)
╰─────────────┴─────┴─────┴─────┴─────┴────────╯
[...] = Bold, Total column highlighted in yellow
The examples/ directory contains sample data files demonstrating various use cases. Try these commands:
Simple data, default styling:
tbl examples/simple.csv┌───────┬─────┬─────────────┐
│ Name ┆ Age ┆ City │
╞═══════╪═════╪═════════════╡
│ Alice ┆ 30 ┆ New York │
├╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Bob ┆ 25 ┆ Los Angeles │
├╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Carol ┆ 28 ┆ Chicago │
└───────┴─────┴─────────────┘
Right-aligned numbers, bold totals, highlighted header:
tbl examples/sales.csv \
--row-headers \
--column-align 2-6:right \
--row-bold 5 \
--column-bold 6 \
--header-bg-color blue \
--header-color white \
--style roundedProfessional financial formatting with row headers (Product names), right-aligned numbers, bold totals row and column.
Spreadsheet-style with row headers and color-coded averages:
tbl examples/grades.csv \
--row-headers \
--column-align 2-6:right \
--header-bold \
--header-color bright-cyan \
--row-header-bold \
--cell-color 6,1:green \
--cell-color 6,3:green \
--cell-color 6,2:yellow \
--cell-color 6,4:green \
--cell-color 6,5:yellowGrade book layout with student names as row headers, right-aligned scores, and color-coded averages (green for A's, yellow for B's).
Status monitoring with color indicators and zebra striping:
tbl examples/servers.csv \
--alt-row-bg white,bright-black \
--row-color 5:yellow \
--row-color 7:red \
--column-bold 2 \
--header-bg-color black \
--header-color cyan \
--header-boldServer monitoring dashboard with zebra striping for readability, warning row in yellow, error row in red, bold status column.
Italic product names, bold prices:
tbl examples/products.csv \
--column-italic 2 \
--column-bold 4 \
--column-align 4-5:right \
--header-underline \
--header-color bright-greenProduct catalog with italicized product names, bold prices, right-aligned numbers, underlined headers.
Export tables for README files:
tbl examples/pricing.csv --style markdown --align center┌────────────────────────────────────────────────────┐
│ Plan Users Storage Support Price │
╞════════════════════════════════════════════════════╡
│ Free 1 5GB Community $0 │
│ Starter 5 50GB Email $9 │
│ Professional 25 500GB Priority $49 │
│ Business 100 2TB 24/7 Phone $199 │
│ Enterprise Unlimited Unlimited Dedicated $499 │
└────────────────────────────────────────────────────┘
Perfect for pasting into markdown documentation.
Compatible with plain text environments:
tbl examples/departments.txt --style ascii --padding 2Note: Auto-detects pipe delimiter (|)
+----------------+-------------+-----------+------------------+
| Department | Employees | Budget | Manager |
+================+=============+===========+==================+
| Engineering | 45 | $2.5M | Sarah Chen |
+----------------+-------------+-----------+------------------+
| Sales | 28 | $1.8M | Michael Torres |
+----------------+-------------+-----------+------------------+
| Marketing | 15 | $1.2M | Jennifer Liu |
+----------------+-------------+-----------+------------------+
| Support | 22 | $900K | David Park |
+----------------+-------------+-----------+------------------+
| HR | 8 | $600K | Emily Rodriguez |
+----------------+-------------+-----------+------------------+
Numeric matrices and data grids:
tbl examples/matrix.csv \
--no-header \
--align center \
--style rounded \
--column-color 1-4:cyan╭──────┬──────┬──────┬───────╮
│ 1.2 ┆ 3.4 ┆ 5.6 ┆ 7.8 │
├╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 2.1 ┆ 4.3 ┆ 6.5 ┆ 8.7 │
├╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 3.0 ┆ 5.2 ┆ 7.4 ┆ 9.6 │
├╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 4.9 ┆ 6.1 ┆ 8.3 ┆ 10.5 │
╰──────┴──────┴──────┴───────╯
Highlighting improvements and regressions:
tbl examples/benchmark.csv \
--row-color 2:yellow \
--row-color 1,3,4,6,7:green \
--column-align 2-4:right \
--column-bold 4 \
--header-bg-color black \
--header-color white \
--alt-row-bg white,bright-blackBenchmark results with green for improvements, yellow for regressions, bold change column.
Minimal borders for dense data:
tbl examples/employees.csv \
--no-outer-border \
--no-column-border \
--header-bold \
--header-color bright-cyan \
--max-width 120Compact formatting with minimal borders, constrained width for terminal display.
Professional accounting layout with row headers:
tbl examples/financial.csv \
--row-headers \
--corner-text "FY2024" \
--corner-color bright-magenta \
--column-align 2-5:right \
--row-bold 3,7 \
--header-bg-color blue \
--header-color white \
--row-header-bg-color green \
--row-header-bold \
--style roundedQuarterly financial statement with custom corner cell, bold subtotals (Gross Profit, Net Income), color-coded headers.
Using text attributes for emphasis:
tbl examples/servers.csv \
--header-bold \
--header-underline \
--column-italic 1 \
--row-crossed-out 7 \
--row-dim 4 \
--column-bold 2Server report with italic server names, bold status, crossed-out offline server, dimmed idle server.
Precise cell formatting for specific data points:
tbl examples/grades.csv \
--cell-bg 2,1:green \
--cell-bg 2,3:green \
--cell-color 3,2:red \
--cell-bold 6,1-6,5 \
--column-align 2-6:rightGrade book with green background for high scores, red text for low score, bold average row.
High-contrast dashboard using reverse attribute:
tbl examples/benchmark.csv \
--header-reverse \
--row-reverse 1,3,4,6,7 \
--column-align 2-4:rightReverse video highlighting for improved/stable metrics.
Combining multiple features for polished output:
tbl examples/sales.csv \
--style rounded \
--row-headers \
--corner-text "Q1-Q4" \
--header-bold \
--header-bg-color blue \
--header-color white \
--row-header-bold \
--row-header-bg-color bright-black \
--column-align 2-6:right \
--column-bold 6 \
--row-bold 5 \
--cell-color 6,5:bright-yellow \
--alt-row-bg white,bright-blackComplete sales report with row headers, rounded corners, zebra striping, bold totals, highlighted grand total cell.
Automatically style cells or rows based on their values using conditional formatting rules.
Apply formatting to entire rows when a condition matches:
tbl examples/test_results.csv \
--row-color-if "Status=Pass:green" \
--row-color-if "Status=Fail:red"Highlights passing tests in green and failing tests in red.
tbl examples/sales.csv \
--row-bg-if "Total<100000:red" \
--row-bg-if "Total>=200000:green" \
--row-color-if "Total<100000:white"Background colors based on sales totals: red for low performers, green for high performers.
tbl examples/test_results.csv \
--row-bold-if "Score>=90" \
--row-dim-if "Score<50" \
--row-italic-if "Testcontains:Gateway"Apply formatting only to cells in specific columns:
tbl examples/test_results.csv \
--cell-color-if "Score<50:red" \
--cell-color-if "Score>=90:green" \
--cell-bold-if "Score>=95"Colors and bolds only the Score column cells based on their values.
tbl examples/financial.csv \
--cell-bg-if "Profit<0:red" \
--cell-color-if "Profit<0:white" \
--cell-bg-if "Profit>100000:green" \
--cell-bold-if "Profit>100000"Conditional formatting uses the syntax: COLUMN OPERATOR VALUE
Column Identifiers:
- By index:
2(1-based column number) - By name:
Status(exact header match)
Numeric Operators:
<- Less than<=- Less than or equal>- Greater than>=- Greater than or equal=- Equal (numeric or string)!=- Not equal (numeric or string)
String Operators:
contains:- Contains substring!contains:- Does not contain substringstarts:- Starts withends:- Ends with
Examples:
# Numeric comparisons
--row-color-if "3<0:red" # Column 3 less than 0
--row-bg-if "Price>=100:yellow" # Price column >= 100
# String matching
--row-color-if "Status=Error:red" # Status equals "Error"
--cell-bold-if "Namecontains:Admin" # Name contains "Admin"
--row-italic-if "Typestarts:WARN" # Type starts with "WARN"Row-level (affects all cells in matching rows):
--row-color-if COL:COND:COLOR- Text color--row-bg-if COL:COND:COLOR- Background color--row-bold-if COL:COND- Bold text--row-underline-if COL:COND- Underlined text--row-dim-if COL:COND- Dimmed text--row-italic-if COL:COND- Italic text
Cell-level (affects only cells in the specified column):
--cell-color-if COL:COND:COLOR- Text color--cell-bg-if COL:COND:COLOR- Background color--cell-bold-if COL:COND- Bold text--cell-underline-if COL:COND- Underlined text--cell-dim-if COL:COND- Dimmed text--cell-italic-if COL:COND- Italic text
# Format ls output
ls -la | awk '{print $1","$3","$5","$9}' | tbl --header
# Format process list
ps aux | head -10 | tr -s ' ' ',' | tbl# Extract, transform, and display
curl -s api.example.com/data.csv | \
grep "active" | \
tbl --style ascii --align center# Preview large CSV
head -20 large_data.csv | tbl --max-width 120# Create markdown tables for docs
tbl config.csv --style markdown >> README.mdtbl automatically detects the most likely delimiter by analyzing:
- Comma (
,) - Tab (
\t) - Pipe (
|) - Semicolon (
;)
The tool chooses the delimiter that appears most consistently across rows.
Headers are auto-detected using heuristics:
- First row has all unique values
- First row is non-numeric while second row contains numbers
- First row differs in pattern from data rows
You can override with --header or --no-header flags.
- Rust 1.70+ (edition 2021)
- Cargo
# Development build
cargo build
# Release build (optimized)
cargo build --release
# Run tests
cargo test
# Run with examples
cargo run -- examples/data.csvtbl can also be used as a Rust library:
use tbl::{read_input, parse_csv, render_table, ParserConfig, TableConfig};
fn main() -> anyhow::Result<()> {
let input = read_input(Some("data.csv".into()))?;
let data = parse_csv(&input, &ParserConfig::default())?;
let output = render_table(&data, &TableConfig::default());
println!("{}", output);
Ok(())
}- clap - Command-line argument parsing
- comfy-table - Table rendering
- csv - CSV parsing
- anyhow - Error handling
Contributions are welcome! Please feel free to submit pull requests or open issues.
# Run tests
cargo test
# Run with logging
RUST_LOG=debug cargo run -- data.csv
# Check formatting
cargo fmt --check
# Run clippy
cargo clippyMIT License - see LICENSE file for details
Kirby Little
Future enhancements may include:
- TSV and JSON input support
- Per-column configuration
- Color schemes and themes
- Export to HTML/LaTeX
- Streaming mode for large files
- Configuration file support
- Column filtering and sorting
- Built with the excellent comfy-table library
- Inspired by command-line tools like
column,csvlook, andmiller