ANSI-TO-TUI(1)
NAME
ansi-to-tui — Convert ansi colored text to tui::text::Text
SYNOPSIS
INFO
91 stars
29 forks
0 views
RustShell & Terminal
DESCRIPTION
Convert ansi colored text to tui::text::Text
README
ansi-to-tui
Convert ANSI color and style codes into Ratatui Text.
This crate parses bytes containing ANSI SGR escape sequences (like \x1b[31m).
It produces a Ratatui Text with equivalent foreground/background Color and
Modifier settings via Style.
Unknown or malformed escape sequences are ignored so you can feed it real terminal output without having to pre-clean it.
| Color Mode | Supported | SGR Example | Ratatui Color Example |
|---|---|---|---|
| Named (3/4-bit, 8/16-color) | ✓ | \x1b[30..37;40..47m | Color::Blue |
| Indexed (8-bit, 256-color) | ✓ | \x1b[38;5;<N>m | Color::Indexed(1) |
| Truecolor (24-bit RGB) | ✓ | \x1b[38;2;<R>;<G>;<B>m | Color::Rgb(255, 0, 0) |
Example
use ansi_to_tui::IntoText as _;
let buffer = std::fs::read("ascii/text.ascii")?;
let output = buffer.into_text()?;
Contributing and CI details are in CONTRIBUTING.md.
SEE ALSO
fzf(1)— A command-line fuzzy finder — interactive Unix filter for any liststarship(1)— The minimal, blazing-fast, and infinitely customizable prompt for any shellzoxide(1)— A smarter cd command — learns your habits and jumps instantlyblade-code(1)— AI-powered CLI coding agent with 20+ built-in tools, MCP support, and multi-model providersqrrs(1)— CLI QR code generator and reader written in rust
clihub3/4/2026ANSI-TO-TUI(1)