tree_fmt
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
Quick Start
use ;
let view = new
.add_row
.add_row
.build_view;
let formatter = new;
let output = formatter.format?;
println!;
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:
Feature Flags
# Default (4 formatters)
= "0.4.0"
# Minimal (single formatter)
= { = "0.4.0", = false, = [ "table_plain" ] }
# Specific use case
= { = "0.4.0", = [ "table_markdown", "format_json" ] }
# Everything
= { = "0.4.0", = [ "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
Documentation & Testing
- Complete Specification - API contract, design rationale, changelog
- Examples - Working code for all formatters
- API Docs - Generated documentation
License
MIT - v0.4.0 - Repository