rich
Rich terminal formatting library for Python — provides colored output, tables, progress bars, markdown rendering, syntax highlighting, logging integration, and more. rich features: Console for rich output, print() with markup [bold red]text[/bold red], Panel/Table/Tree/Columns layout, Progress for progress bars, Live for live-updating displays, Syntax for syntax-highlighted code, Markdown rendering, Spinner, Rule for horizontal lines, Inspect() for object inspection, pretty-printing, logging.RichHandler, Traceback for beautiful exceptions, and Style for complex formatting.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Terminal formatting library. Do not render secrets in rich output — they appear in terminal history. markup=False for user-controlled content (prevents markup injection). ANSI codes in logs may leak to log aggregators.
⚡ Reliability
Best When
CLI tools, agent output formatting, developer tooling, and any terminal application needing beautiful output — rich is the standard for Python terminal formatting.
Avoid When
Log files (ANSI codes in files), Jupyter notebooks (use ipywidgets), high-frequency output, or piped output where ANSI codes are unwanted.
Use Cases
- • Agent formatted output — from rich import print; print('[bold green]✓[/bold green] Task completed'); print('[red]Error:[/red] Something failed'); from rich.console import Console; console = Console(); console.print('Data:', data, style='cyan') — colored output; agent produces readable terminal output with colors and styles
- • Agent tables — from rich.table import Table; from rich import print; table = Table(title='Results'); table.add_column('Name', style='cyan'); table.add_column('Score', justify='right', style='green'); for name, score in results: table.add_row(name, str(score)); print(table) — table; agent renders structured data as terminal table
- • Agent progress bar — from rich.progress import Progress; with Progress() as progress: task = progress.add_task('[cyan]Processing...', total=len(items)); for item in items: process(item); progress.advance(task) — progress; agent shows progress for long-running loops; multiple tasks supported simultaneously
- • Agent live display — from rich.live import Live; from rich.table import Table; with Live(refresh_per_second=4) as live: for i in range(100): table = build_table(data[:i]); live.update(table) — live update; agent updates terminal display in-place (like a dashboard); refresh_per_second controls update rate
- • Agent syntax highlight — from rich.syntax import Syntax; from rich import print; code = open('script.py').read(); syntax = Syntax(code, 'python', theme='monokai', line_numbers=True); print(syntax) — code display; agent displays code with syntax highlighting in terminal; useful for code review agents
Not For
- • Non-interactive output — rich ANSI codes appear as garbage in log files; use rich with force_terminal=True carefully or check IS_TERMINAL
- • Jupyter notebooks — rich works in Jupyter but ipywidgets or tqdm has better notebook integration
- • High-frequency output — rich formatting has overhead; for thousands of lines/second use plain print
Interface
Authentication
No auth — terminal formatting library.
Pricing
rich is MIT licensed. Free for all use.
Agent Metadata
Known Gotchas
- ⚠ from rich import print shadows builtin print — from rich import print replaces builtin print in that module; print() from rich accepts markup; if you import both: use builtins.print for plain; or use Console().print() to avoid shadowing; agent code: prefer Console().print() over from rich import print to avoid confusion
- ⚠ Console auto-detects TTY — Console() auto-disables colors when not connected to TTY (CI, piped); force_terminal=True overrides; Console(highlight=False) for no auto-highlighting; Console(no_color=True) for plain; agent code checking if in TTY: console.is_terminal; logging to file: use Console(file=open('out.log', 'w'), markup=False, highlight=False)
- ⚠ Markup uses square brackets — [bold red]text[/bold red]; to render literal square brackets: escape with backslash or [[] for [; Console(markup=False) disables all markup; agent code printing user data with [ characters: use console.print(data, markup=False) or escape: data.replace('[', r'\[')
- ⚠ Live context conflicts with other output — using print() inside Live context corrupts display; use live.console.print() inside Live block; Progress uses Live internally; agent code: inside with Live() or with Progress(): use the live/progress console object for all output; avoid mixing with plain print
- ⚠ Table columns need explicit width for long data — Table default auto-sizes columns but very long text wraps or truncates; add_column('Name', max_width=30, no_wrap=True) for fixed width; add_column('Data', overflow='fold') for folded long text; agent code: always set max_width for user-data columns to prevent table overflow
- ⚠ from rich.progress import track for simple loops — track(iterable, description='Processing') is simplest progress: for item in track(items, description='Working...'): process(item); creates progress bar automatically; for multiple tasks use Progress() context manager; for known total: track(items, total=len(items))
Alternatives
Full Evaluation Report
Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for rich.
AI-powered analysis · PDF + markdown · Delivered within 30 minutes
Package Brief
Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.
Delivered within 10 minutes
Score Monitoring
Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.
Continuous monitoring
Scores are editorial opinions as of 2026-03-06.