prettytable-rs
Print aligned, styled, and formatted tables in the terminal from Rust.
Repository Health
Technical Analysis
prettytable-rs is a Rust library for rendering neatly aligned and formatted tables in the terminal. You build a table from rows and cells — or with the convenient table! and row! macros — and it handles column-width alignment, borders, and separators so the output lines up cleanly regardless of content length.
Cells support rich styling including foreground and background colors, bold, italic, and text alignment, and tables can be customized with different border and separator formats or sliced into sub-views. It also supports importing from and exporting to CSV, making it easy to turn tabular data into readable console output. With over 21 million downloads it is a long-standing staple for CLI tools that need to display structured data.
What You Get
- A Table/Row/Cell model with automatic column-width alignment and clean borders
- table! and row! macros for terse, declarative table construction
- Per-cell styling: foreground/background colors, bold, italic, and text alignment
- Configurable table formats and separators, plus slicing into sub-tables
- Optional CSV import and export for turning data files into formatted console output
Common Use Cases
- Displaying structured results or status summaries in a command-line tool
- Rendering query results or reports as aligned tables in the terminal
- Converting CSV data into readable, styled console tables
Under The Hood
Architecture The crate is organized by domain module under src: table logic in lib.rs, row.rs, and cell.rs model the data structure, format.rs defines borders/separators and the TableFormat presets, utils.rs handles width and display helpers, and csv.rs provides feature-gated import/export. Rendering walks rows to compute per-column widths, then prints each cell padded and styled according to its Cell attributes. The table!/row! macros expand into the same construction calls.
Tech Stack Pure Rust (100% of the codebase), edition 2018, distributed on crates.io. Styling is backed by the term crate for terminal colors, with optional csv support behind a feature flag. It also ships an evcxr integration for rendering tables in Jupyter-style Rust notebooks and a fuzz target for robustness testing.
Code Quality The codebase has an examples directory, CI configured across Travis and AppVeyor, code-coverage reporting via codecov, and a fuzz harness — solid signals for a mature crate, though Cargo.toml marks maintenance as passively-maintained and the last release was 0.10.0 in 2022.
API Design The Table/Row/Cell model is intuitive and the table!/row! macros make the common case a one-liner, while style and color specifiers are concise strings. A thorough README with sections on styling, slicing, CSV, and notebook integration keeps the learning curve low for anyone who has used a spreadsheet mental model.
Used by 2 apps in this directory
mnemo
AI Agents · AI Development
A local-first AI memory sidecar that extracts entities, builds a persistent knowledge graph, and injects ranked context into any LLM pipeline — no cloud required.
OpenObserve
Monitoring · Analytics · Devops
Open source observability platform for logs, metrics, traces, and real user monitoring — delivering 140x lower storage costs than Elasticsearch with a single binary you can run in under 2 minutes.