termcolor
ANSI color formatting for terminal output in Python
Repository Health
Technical Analysis
termcolor is a lightweight Python library that adds ANSI color and text-attribute formatting (bold, underline, blink, etc.) to strings printed to a terminal. It exposes a simple colored() function plus a cprint() convenience wrapper around print(), and can also be invoked as a CLI (python -m termcolor) to preview available colors.
Because colorizing terminal output is a near-universal need for CLI tools, test runners, and logging utilities, termcolor is one of the most widely depended-on small utility packages in the Python ecosystem, valued for having effectively zero API surface to learn and no dependencies.
What You Get
- A
colored()function supporting 8 standard foreground/background colors plus “light” variants, and text attributes (bold, dark, underline, blink, reverse, concealed) - A
cprint()convenience function combining coloring and printing in a single call - Automatic color-disabling detection via
NO_COLORandANSI_COLORS_DISABLEDenvironment variables, and non-TTY output detection - A
__main__.pyCLI entry point (python -m termcolor) that prints a demo of all supported colors and attributes - Full type hints and a fully tested, dependency-free implementation
Common Use Cases
- CLI tools highlighting success/error/warning output in different colors for readability
- Test runners and linters coloring pass/fail or severity-level output
- Logging utilities that want colorized log levels without pulling in a heavier logging framework
- Scripts and build tools that need simple, dependency-free terminal color output across platforms
Under The Hood
Architecture: The library is a single-module implementation (src/termcolor/termcolor.py, 223 lines) exposing colored() and cprint(), backed by dictionaries mapping color/attribute names to ANSI escape codes; __init__.py re-exports the public API and __main__.py implements the python -m termcolor demo CLI. Tech Stack: Pure Python 3.10+ with zero runtime dependencies, packaged via Hatchling with hatch-vcs for version derivation from git tags; pyproject.toml fully declares metadata (no setup.py), and .pre-commit-config.yaml enforces formatting/linting before commits land. Code Quality: tests/test_termcolor.py provides direct unit coverage of the color/attribute combinations and the environment-variable-based disable logic; the codebase is small enough that the entire implementation surface is easily auditable, and CI runs across Python 3.10 through 3.15 per the classifiers in pyproject.toml. API Design: The public API is intentionally minimal — one function to colorize a string, one to colorize-and-print — requiring no configuration or setup, which is precisely why it remains a default choice for adding terminal color without adopting a larger CLI framework.
Used by 6 apps in this directory
Apache Airflow
Data Engineering
Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.
ClickHouse
Databases · Analytics · Data Engineering
Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.
OpenHands
AI Code Assistants · AI Development
The self-hosted developer control center for running AI coding agents — locally, in Docker, on VMs, or across cloud backends — with automation workflows for GitHub, Slack, and more.
QRev
CRM · AI Agents
Open source AI-first sales platform that replaces Salesforce with autonomous agents handling prospecting, outreach, and lead management at scale.
Social Analyzer
Security
Find and analyze a person's digital footprint across 1000+ social media platforms using multi-layer detection, OCR, and metadata extraction.
Timeplus Proton
Data Engineering · Analytics
Single C++ binary SQL engine for real-time stream processing, ETL, and analytics on Kafka, Redpanda, and ClickHouse with sub-millisecond latency.