ascii_table
Print ASCII tables to the terminal.
Example
use ::ascii_table::AsciiTable;
let ascii_table = AsciiTable::new();
let data = &[&["1", "2", "3"], &["4", "5", "6"], &["7", "8", "9"]];
ascii_table.println(data);
// ┌───┬───┬───┐
// │ 1 │ 2 │ 3 │
// │ 4 │ 5 │ 6 │
// │ 7 │ 8 │ 9 │
// └───┴───┴───┘
Example
use ::ascii_table::{Align, AsciiTable, Width};
let mut ascii_table = AsciiTable::new();
ascii_table.set_max_width(Width::Fixed(26));
ascii_table
.column(0)
.set_header("H1")
.set_align(Align::Left);
ascii_table
.column(1)
.set_header("H2")
.set_align(Align::Center);
ascii_table
.column(2)
.set_header("H3")
.set_align(Align::Right);
let data: &[&[&str]] = &[&["v", "v", "v"], &["123", "456", "789", "abcdef"]];
ascii_table.println(data);
// ┌─────┬─────┬─────┬──────┐
// │ H1 │ H2 │ H3 │ │
// ├─────┼─────┼─────┼──────┤
// │ v │ v │ v │ │
// │ 123 │ 456 │ 789 │ abc+ │
// └─────┴─────┴─────┴──────┘
Features
auto_table_width: Sets the default max width of the Ascii Table to the width of the terminal.color_codes: Correctly calculates the width of a string when terminal color codes are present (like those from thecolorfulcrate).wide_characters: Correctly calculates the width of a string when wide characters are present (like emoji's).
Changelog
v5.0.0 (2025-11-30)
- Complete rewrite. All the features are still the same except Ascii Table no longer accepts 2D arrays
of
Display. You will have to stringify your data before you give it to Ascii Table.
v4.0.8 (2025-10-12)
- Replaced the crate
termsizewithtermizeto fix a edge-case where it was unable to get the terminal width on some SSH sessions. This will only affect theauto_table_widthfeature.
v4.0.7 (2025-05-14)
- Replaced the crate
lazy_staticwithstd::sync::LazyLock. This change is only for thecolor_codesfeature.
v4.0.6 (2025-02-25)
- Bumped Rust edition to 2024.
- Replaced
termionwith the more lightweighttermsize. This will only affect theauto_table_widthfeature.
v4.0.5 (2024-11-20)
- Bumped crate unicode-width from 0.1 to 0.2.
v4.0.4 (2024-08-28)
- Bumped versions on 3rd party crates.
v4.0.3 (2023-08-28)
- Added documentation to explain Ascii Table's features.
- Some minor refactoring.
v4.0.2 (2022-01-25)
- Created a new feature
auto_table_width. It will set the default max width of your ascii table to the width of your terminal. Note thatAsciiTable::set_max_widthwill override this value. - Changed ascii table default max width from 80 to 100.
v4.0.1 (2022-01-24)
- Moved color code parsing to its own feature
color_codes. Enable this feature when you want to display colors in the terminal using thecolorfulcrate. - Created a new feature
wide_characterswho will use unicode rules to determine the width of strings. Use this feature when you want to display emoji's or other wide characters.
v4.0.0 (2022-01-23)
- Revamped API.