colored

The simplest way to add ANSI colors and styles to terminal strings in Rust.

Library
Cargo
v3.1.1
2,042 stars
Mozilla Public License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
43 /100 Fair
Development Activity 0
Maintenance 20
Community 52
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
76 /100 Good
Architecture 75
Code Quality 78
Innovation 65
Learning Curve 85

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 Colorize extension 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_COLOR and CLICOLOR/CLICOLOR_FORCE environment-variable handling for well-behaved CLI output
  • An optional no-color Cargo 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_COLOR for 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

Rust
63%
MIT

PostgresML

AI Development · Databases

6,823

Run ML training and LLM inference natively inside PostgreSQL with GPU acceleration — no data movement required.

View details
51
Repo Health
76
Technical
64
Dependency
Built with
Rust 63%
JavaScript 11%
Updated 1 years ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

40,397

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.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated 5 days ago
Rust
90%
Apache 2.0

Qdrant

AI Development · Databases · Search

35,220

Open-source vector database and search engine built in Rust for production-grade AI applications — from semantic search to RAG pipelines and recommendation systems.

View details
92
Repo Health
87
Technical
62
Dependency
Built with
Rust 90%
Updated 6 days ago
Rust
79%
AGPL 3.0

Spacedrive

Collaboration · File Storage

39,292

One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.

View details
84
Repo Health
84
Technical
63
Dependency
Built with
Rust 79%
TypeScript 18%
Updated 2 weeks ago
Rust
66%
Apache 2.0

Temps

Analytics · Devops · Monitoring

865

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.

View details
81
Repo Health
86
Technical
66
Dependency
Built with
Rust 66%
TypeScript 33%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers