colored
The simplest way to add ANSI colors and styles to terminal strings in Rust.
Repository Health
Technical Analysis
colored is a Rust crate that adds a Colorize trait directly onto &str and String, so any string can be colored or styled by chaining calls like .red(), .on_blue(), or .bold(). It covers the standard 8 ANSI colors plus bright variants, background colors, and text styles such as bold, underline, italic, dimmed, and strikethrough, all without requiring users to learn a separate builder API.
Beyond basic named colors, colored supports truecolor (24-bit RGB) foreground and background colors, hex color strings, and dynamic color selection from runtime strings. It also respects terminal color conventions out of the box — honoring NO_COLOR and CLICOLOR/CLICOLOR_FORCE environment variables — and works across Linux, macOS, and Windows (including PowerShell).
What You Get
- A
Colorizeextension trait adding.red(),.blue(),.on_green(),.bright_yellow(), etc. directly to strings - Text styling methods:
.bold(),.underline(),.italic(),.dimmed(),.reversed(),.blink(),.hidden(),.strikethrough() - Truecolor (24-bit RGB) support via
.truecolor(r,g,b),.custom_color(), and hex-string colors like.color("#0057B7") - Automatic
NO_COLORandCLICOLOR/CLICOLOR_FORCEenvironment-variable handling for well-behaved CLI output - An optional
no-colorCargo feature to strip all color output at compile time - Cross-platform support for Linux, macOS, and Windows (including PowerShell) terminals
Common Use Cases
- Highlighting success/error/warning output in a command-line tool without hand-writing ANSI escape codes
- Building colorized diff, log, or test-runner output that still degrades gracefully when piped to a file
- Adding branded truecolor output to a CLI while respecting
NO_COLORfor accessibility and CI environments - Prototyping terminal UIs or REPLs that need quick, readable color-coded text without a full TUI framework
Under The Hood
Architecture: The crate’s core is a ColoredString wrapper (src/lib.rs) produced by the Colorize trait, which is implemented for &str and String. Color and style state is tracked in a small struct backed by the enums defined in src/color.rs (Color) and src/style.rs (Style, bitflags-style for combinable styles like bold+underline), and src/customcolors.rs adds a CustomColor type for arbitrary RGB values. src/formatters.rs implements Display/fmt::Debug for ColoredString, translating the tracked state into ANSI escape sequences only at format time, which is what lets a colored string still work correctly with Rust’s format specifiers (padding, truncation) as shown in the README’s format!("{:30}", ...) example. src/control.rs centralizes the NO_COLOR/CLICOLOR/CLICOLOR_FORCE environment-variable checks so every formatter respects the same global on/off state. Tech Stack: Rust 2021 edition, minimum supported Rust version 1.80; the only runtime dependency is windows-sys (gated to cfg(windows)) for Windows console color support — everything else is std-only. Dev-dependencies (insta for snapshot testing, rspec for spec-style tests, ansiterm for compatibility testing) are test-only. The crate enables Clippy’s pedantic/nursery/correctness lint groups as warnings, showing an intentionally strict internal quality bar. Code Quality: The crate ships a real test suite — tests/ansi_term_compat.rs checks compatibility with the ansiterm crate’s output, and snapshot tests under src/snapshots/ (via insta) pin exact colored output for both color-enabled and no-color builds, catching accidental formatting regressions. Combined with the strict Clippy lint configuration in Cargo.toml, this indicates an actively quality-gated codebase, though GitHub activity data shows currently low commit velocity relative to its age. API Design: The trait-based Colorize design is the crate’s biggest ergonomic win — no wrapper types or builder calls are needed at the call site, just .red() chained onto any string literal, which is why the README can claim ‘coloring terminal so simple you already know how to do it.’ Style and color calls compose freely (.on_blue().red().bold()), and the crate documents an escape hatch (.clear()/.normal()) for resetting state, keeping the API small and discoverable without a generated-docs deep dive.
Used by 14 apps in this directory
PostgresML
AI Development · Databases
Run ML training and LLM inference natively inside PostgreSQL with GPU acceleration — no data movement required.
PostHog
Ab Testing Experimentation · Analytics · Developer Tools
The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.
Qdrant
AI Development · Databases · Search
Open-source vector database and search engine built in Rust for production-grade AI applications — from semantic search to RAG pipelines and recommendation systems.
Spacedrive
Collaboration · File Storage
One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.
Temps
Analytics · Devops · Monitoring
A self-hosted Rust PaaS that replaces Vercel, Sentry, PostHog, Pingdom, Resend, and E2B with one binary — plus 440+ CLI operations agents like Claude Code can drive directly.