#formatter #hierarchical #display #table-formatter #tree

tree_fmt

Multi-format data visualization library with 10 formatters, 31 variants, and granular per-variant feature flags for minimal binary size

4 releases (breaking)

new 0.8.0 Dec 21, 2025
0.7.0 Dec 12, 2025
0.6.0 Dec 4, 2025
0.5.0 Oct 25, 2025

#130 in Visualization

Download history 127/week @ 2025-10-24 75/week @ 2025-11-28 2/week @ 2025-12-05 27/week @ 2025-12-12

104 downloads per month
Used in 2 crates

MIT license

195KB
4K SLoC

tree_fmt

Crates.io Documentation License: MIT

Multi-format data visualization library: 10 formatters, 31 variants, zero core dependencies.

Why tree_fmt?

Build once, format anywhere: Create your data structure once, then output as ASCII table, JSON, HTML, SQL, YAML, tree view, or 6 other formats - without rebuilding data. Features granular compilation (31 flags) and zero core dependencies.

Installation

cargo add tree_fmt  # Default: table, tree, expanded, logfmt
cargo add tree_fmt --no-default-features --features table_plain  # Minimal

Quick Start

use tree_fmt::{ RowBuilder, TableFormatter, Format };

let view = RowBuilder::new( vec![ "Name".into(), "Age".into() ] )
  .add_row( vec![ "Alice".into(), "30".into() ] )
  .add_row( vec![ "Bob".into(), "25".into() ] )
  .build_view();

let formatter = TableFormatter::new();
let output = formatter.format( &view )?;
println!( "{}", output );

Output:

 Name   Age
 -----  ---
 Alice  30
 Bob    25

Formatters & Features

Format Use Case Variants Feature Flags Example
Table CLI tools, terminals 9 styles table_plain, table_markdown, table_csv, table_bordered, table_grid, table_unicode, table_minimal, table_tsv, table_compact
Tree File trees, hierarchies 3 styles tree_hierarchical, tree_aligned, tree_aggregated
Expanded PostgreSQL \x mode 2 styles expanded_postgres, expanded_property
JSON APIs, config files Pretty/Compact format_json
HTML Web dashboards 4 themes html_minimal, html_bootstrap, html_tailwind, html_custom
SQL Database seeds 4 dialects sql_ansi, sql_postgres, sql_mysql, sql_sqlite
YAML Config export Standard format_yaml
TOML Cargo.toml gen Standard format_toml
Logfmt Structured logs Standard format_logfmt
Text Docs, CLI help 6 styles format_text

Total: 31 variants across 10 formatters · Detailed variant docs →

Run examples:

cargo run --example table_format --all-features
cargo run --example unified_formats --all-features

Feature Flags

# Default (4 formatters)
tree_fmt = "0.4.0"

# Minimal (single formatter)
tree_fmt = { version = "0.4.0", default-features = false, features = [ "table_plain" ] }

# Specific use case
tree_fmt = { version = "0.4.0", features = [ "table_markdown", "format_json" ] }

# Everything
tree_fmt = { version = "0.4.0", features = [ "all_formats" ] }

31 granular flags available - each variant has its own flag for minimal binary size.

Meta-features: format_table (all 9 table variants), format_html (all 4 HTML variants), format_sql (all 4 SQL dialects), visual_formats, data_formats, all_formats

Complete feature guide →

Documentation & Testing

cargo test --all-features           # Run tests
cargo doc --open --all-features    # View docs locally

License

MIT - v0.4.0 - Repository

Dependencies

~1.6–2.5MB
~41K SLoC