termcolor

Simple ANSI terminal color library for Python — adds color and style to terminal text with minimal API. termcolor features: colored(text, color, on_color, attrs) for colored strings, cprint() for direct colored printing, NO_COLOR environment variable support, FORCE_COLOR for forcing colors in non-TTY, support for colors (red/green/yellow/blue/magenta/cyan/white/grey), highlights (on_red/on_green etc.), attributes (bold/dark/underline/blink/reverse/concealed), Python 3.8+ support, and zero dependencies. Much simpler than colorama but Unix/macOS focused.

Evaluated Mar 06, 2026 (0d ago) v2.x
Homepage ↗ Repo ↗ Developer Tools python termcolor colors terminal ansi cli formatting
⚙ Agent Friendliness
69
/ 100
Can an agent use this?
🔒 Security
92
/ 100
Is it safe for agents?
⚡ Reliability
90
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
88
Error Messages
85
Auth Simplicity
99
Rate Limits
99

🔒 Security

TLS Enforcement
92
Auth Strength
92
Scope Granularity
90
Dep. Hygiene
95
Secret Handling
90

Pure terminal formatting library with zero dependencies and no network calls. No security concerns. Colored output containing sensitive values is just as exposed as plain text — don't add color to masked credentials.

⚡ Reliability

Uptime/SLA
88
Version Stability
90
Breaking Changes
90
Error Recovery
90
AF Security Reliability

Best When

Simple colored terminal output on Unix/macOS — termcolor's minimal API (one function, zero dependencies) is perfect for adding basic color to CLI tools without framework overhead.

Avoid When

Windows support needed (use colorama), 256-color output (use rich/blessed), or complex terminal UI (use textual).

Use Cases

  • Agent status output — from termcolor import colored, cprint; cprint('SUCCESS', 'green', attrs=['bold']); cprint('FAILED', 'red', attrs=['bold']); cprint('WARNING', 'yellow') — colored status; agent CLI output uses color coding for quick status scanning; cprint() is colored + print() in one call
  • Agent log level coloring — from termcolor import colored; levels = {'DEBUG': 'cyan', 'INFO': 'white', 'WARNING': 'yellow', 'ERROR': 'red', 'CRITICAL': ('red', 'on_white')}; def color_log(level, msg): color = levels.get(level, 'white'); print(f'{colored(level, color)}: {msg}') — colored log levels; agent custom logger colors by level
  • Agent diff display — from termcolor import colored; for line in diff: if line.startswith('+'): print(colored(line, 'green')); elif line.startswith('-'): print(colored(line, 'red')); else: print(line) — colored diff; agent shows changes with green additions and red removals
  • Agent table header — from termcolor import colored; headers = ['Name', 'Status', 'Score']; header_row = ' | '.join(colored(h, attrs=['bold', 'underline']) for h in headers); print(header_row) — styled headers; agent table output uses bold underlined headers; colored() returns string for composition
  • Agent error highlighting — from termcolor import colored; error_msg = colored(str(e), 'red', attrs=['bold']); context = colored(f'while processing {item.name}', 'yellow'); print(f'{error_msg} {context}') — highlighted errors; agent error output stands out from normal output; mixed styled text with string composition

Not For

  • Windows compatibility — termcolor has limited Windows ANSI support; for Windows use colorama
  • 256-color or True Color — termcolor supports only 8 basic colors; for rich colors use rich or blessed
  • Complex terminal UI — termcolor is for colorizing text only; for TUI use rich, blessed, or textual

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No auth — local terminal formatting library.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

termcolor is MIT licensed. Free for all use.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • ANSI codes in non-TTY produce raw escape sequences — colored('text', 'red') always returns ANSI-wrapped string; in non-TTY (file redirect, subprocess): output shows raw escape codes like \033[31mtext\033[0m; detect TTY: if sys.stdout.isatty(): use colored(); else: use plain text; or set NO_COLOR=1 env var to disable
  • NO_COLOR environment variable disables all colors — if os.environ.get('NO_COLOR'): colored() returns plain text; agent testing colored output must unset NO_COLOR; agent CI environments with NO_COLOR=1 produce plain output — ensure tests don't assert on ANSI codes
  • Nested colored() calls stack ANSI codes — colored(colored('text', 'red'), 'bold') wraps both codes; text shows as red AND bold; reset at end clears all; but intermediate reset from inner colored() may disrupt outer color; agent code with nested styles should use attrs= parameter: colored('text', 'red', attrs=['bold'])
  • attrs must be a list not string — colored('text', attrs='bold') raises ValueError; must be: colored('text', attrs=['bold']); multiple attrs: colored('text', 'red', attrs=['bold', 'underline']); common mistake from reading docs examples incorrectly
  • Grey is spelled 'grey' not 'gray' — colored('text', 'gray') raises ValueError: invalid color; correct spelling: colored('text', 'grey'); agent code copy-pasting from colorama documentation uses 'gray' which fails with termcolor
  • Reset not always emitted — colored() wraps with ANSI start and reset codes; but if terminal resets mid-sequence (terminal crash, Ctrl+C during print): subsequent output may inherit last color; agent CLI tools should print a final: print(colored('', 'white')) or similar reset on exit

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for termcolor.

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-06.

5229
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered