CLI tool
Nukesor/comfy-table avatar
Nukesor/comfy-table

comfy-table for width-aware terminal tables in Rust

:large_orange_diamond: Build beautiful terminal tables with automatic content wrapping

1,409 stars47 forksRustMIT

At a glance

What is it?
comfy-table is a Rust library for formatting terminal tables with automatic wrapping, column constraints, Unicode borders, and ANSI styling. It fits Rust CLI tools that need readable output in interactive terminals, redirected logs, and other terminal-oriented environments.
Who is it for?
Adopt comfy-table for Rust command-line tools that need readable, width-constrained output, especially when Unicode styling and terminal detection matter. Do not choose it for a fixed-format report that requires identical columns in every environment.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 28 days ago.
What is it written in?
Mainly Rust, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

Why comfy-table exists for terminal output

comfy-table solves a narrow but common Rust presentation problem: turning rows of text and cell metadata into a readable table without manually calculating padding, line breaks, or borders. It is a library rather than a command-line application, so it is intended for developers building CLI tools, diagnostics, inventory views, and other programs that print structured terminal data. The README describes the package as an easy-to-use library for building terminal tables with automatic content wrapping.

The central constraint is terminal width. A table that looks reasonable on a wide workstation can exceed the available area in a narrow terminal or produce undesirable output in a redirected log. Comfy-table addresses this through `ContentArrangement::Dynamic` and `set_width`. When a width is set, the library arranges cell content to fit that target. When no width is explicitly set and the program runs in a terminal, the README says the terminal size is used.

This makes the library relevant to more than decorative formatting. Column constraints, alignment, borders, padding, and multiline content all affect whether a table remains legible. A CLI that receives long file paths, user-entered values, or error messages can constrain columns rather than allowing one unusually long value to determine the entire display width.

How dynamic cell arrangement changes the table

The basic API creates a `Table`, adds a header with `set_header`, adds rows with `add_row`, and prints the table through its `Display` implementation. Cells can be supplied as strings or as `Cell` values. A string containing newline characters is treated as multiline content, which is visible in the README example where one cell contains `Now\nadd some\nmulti line stuff`.

Dynamic arrangement is enabled by calling `set_content_arrangement(ContentArrangement::Dynamic)`. The table then uses its configured width to wrap and distribute content across the available columns. The library also exposes per-cell alignment and per-column defaults. In the README example, the third column is configured with `column_mut(2).expect("Our table has three columns")`, followed by `column.set_cell_alignment(CellAlignment::Right)`. This demonstrates two levels of control: a single cell can be centered, while an entire column can default to right alignment.

The arrangement model has a practical consequence. Wrapping is not merely a display setting added after formatting; it is part of how the table is laid out. If content is too large for the requested width, the output can become taller and some strings will span multiple physical lines. Developers who need a fixed number of output lines should account for that behavior rather than assuming one row always produces one terminal line.

Rust installation and first table example

The repository identifies `comfy-table` as a Cargo package, but the README does not provide an explicit installation command. The package metadata names `comfy-table`, version `8.0.1`, and requires Rust `1.88` or newer under the `rust-version` field. The README points users to the Crates.io package page and the docs.rs documentation for obtaining and reading the library.

Once the dependency is available to a Rust project, the README's basic example creates a table and prints it. The code below is copied from that example. A new program should see three headers and two data rows, with the multiline value in the second row occupying several lines in the middle cell.

rust
use comfy_table::Table;

fn main() {
    let mut table = Table::new();
    table
        .set_header(vec!["Header1", "Header2", "Header3"])
        .add_row(vec![
            "This is a text",
            "This is another text",
            "This is the third text",
        ])
        .add_row(vec![
            "This is another text",
            "Now\nadd some\nmulti line stuff",
            "This is awesome",
        ]);

    println!("{table}");
}

This first use uses the library's default table arrangement. It does not impose a width or terminal-based dynamic sizing. The README says the basic table becomes as wide as its content, so this example is useful for confirming basic rendering before adding styles or terminal-width behavior.

Unicode presets, cell styling, and terminal detection

Comfy-table supports style presets and preset modifiers. The README example loads `UTF8_FULL` and applies `with_rounded_corners()`, producing rounded Unicode borders. It then combines the preset with dynamic arrangement, an explicit width of `40`, cell-level alignment, and a column-level right alignment.

ANSI styling is available through `Cell` methods such as `add_attribute`, `fg`, `bg`, and `add_attributes`. The documented attributes include `Attribute::Bold` and `Attribute::SlowBlink`, while colors are set through the `Color` enum. These features let a command-line application distinguish headers, warnings, status values, or other categories without assembling escape sequences manually.

The default Cargo feature is `tty`, and the manifest also defines `custom_styling`, `reexport_crossterm`, `tty`, `_debug`, and `_integration_test` features. The default `tty` feature brings in `crossterm`. The README states that terminal size detection applies when the program runs in a terminal, while the repository includes `examples/readme_table_no_tty.rs`, indicating that non-TTY behavior is handled as a separate example rather than assumed to be identical to interactive output.

That distinction matters for adoption. ANSI colors and Unicode characters can render differently across terminals, while redirected output may not have a meaningful terminal width. The project supports styling and terminal detection, but the README does not claim universal rendering across every terminal emulator or output destination.

Feature freeze, releases, and upgrade boundaries

The repository is not archived, and the last push was on 2026-09-25. The maintenance picture is more nuanced than the repository status alone. The README says the project can be considered finished, that major planned features are present, and that a search for a new maintainer is ongoing. It also says the project is in a feature freeze until a new maintainer is found.

Under the project's own definition of finished, Comfy-table still receives version bumps for a small number of dependencies, lingering bugs are fixed, and new releases are pushed when requested or after bug fixes are merged. The release list includes `v8.0.0` on 2026-08-05, while `Cargo.toml` currently declares version `8.0.1`. A consumer should inspect the package version and release notes when pinning dependencies rather than inferring the current version from a README badge or the release list.

The manifest identifies the MIT license. This is a relevant adoption fact because the library is distributed under a permissive license, but compatibility with a particular application's licensing requirements remains a matter for its legal and compliance process. The repository's `CHANGELOG.md`, `Cargo.toml`, and release history are the project-specific sources for checking upgrade changes.

Where comfy-table is the wrong choice

Comfy-table is a terminal formatting library, not a general-purpose table renderer for web pages, images, PDF files, or machine-oriented exchange formats. Its output depends on character width, terminal capabilities, Unicode rendering, and the selected arrangement. A program that needs a stable CSV column count or a fixed serialization schema should use a format designed for structured data and leave terminal presentation as a separate concern.

There is also a boundary around terminal width. The README explains that dynamic arrangement uses the terminal size when no explicit width is set and the program runs in a terminal. It does not establish that redirected output will use the same width as an interactive session. Programs that run in CI, pipes, containers, or non-TTY environments should verify the behavior rather than assume interactive layout.

Compared with manually formatting rows, comfy-table adds styling, Unicode, wrapping, and constraint machinery, but it also introduces a dependency and a rendering model intended for human reading. Compared with serialization libraries, it does not replace CSV, JSON, or another interchange format. The appropriate choice depends on whether the application boundary is human-facing terminal output or portable structured data.

Editorial conclusion

Adopt comfy-table for Rust command-line tools that need readable, width-constrained output, especially when Unicode styling and terminal detection matter. Do not choose it for a fixed-format report that requires identical columns in every environment. Verify first that the chosen table width, Unicode output, ANSI colors, and default `tty` feature match every execution environment.

Frequently asked questions

How do I install comfy-table in a Rust project?

The README does not show an explicit installation command. It links to the Crates.io package page and docs.rs, while `Cargo.toml` identifies the package as `comfy-table` and requires Rust `1.88` or newer.

How does comfy-table wrap long terminal table content?

Enable `ContentArrangement::Dynamic` and set a width with `set_width`. According to the README, content is dynamically arranged to fit the configured table width. Without an explicit width, an interactive program uses the terminal size.

Does comfy-table support colors and Unicode table borders?

Yes. The README documents ANSI cell attributes and foreground or background colors. Its styled example also loads the `UTF8_FULL` preset before applying rounded corners.

Is comfy-table adding new features?

The README says the project is in a feature freeze while it searches for a new maintainer. It still describes bug fixes, requested releases, and dependency version bumps as part of the project's finished-state maintenance model.

Official sources

  1. Issues
  2. License: MIT
  3. Nukesor/comfy-table on GitHub
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/nukesor-comfy-table.svg)](https://hysenlabs.com/projects/nukesor-comfy-table)

Was this useful?