ConfigsApr 14, 2026·3 min read

Rich — Beautiful Formatting in the Python Terminal

Rich renders beautiful text, tables, progress bars, markdown, syntax-highlighted code, and tracebacks in the terminal. It turns any Python CLI into a polished UX with a few lines of code and is the backbone of Textual and pip.

Introduction

Rich makes Python terminals beautiful. Written by Will McGugan (also creator of Textual), it renders color, styles, tables, trees, progress bars, spinners, markdown, JSON, and syntax-highlighted tracebacks — all with automatic terminal width detection and graceful fallback on legacy terminals.

With over 50,000 GitHub stars, Rich is used by pip (the error output), Poetry, dbt, and thousands of other tools to turn plain CLIs into polished user experiences.

What Rich Does

Rich provides a Console object that replaces print() with styled output. It supports BBCode-like markup ([bold red]text[/bold red]), automatic line wrapping, tables with auto-sizing columns, progress bars, trees, panels, markdown rendering, syntax highlighting for 100+ languages, and prettier Python tracebacks.

Architecture Overview

[Your Code]
    |
[Console] --> [Renderables]
    |            |
    |            +-- Text, Table, Tree, Panel
    |            +-- Progress, Status, Live
    |            +-- Markdown, Syntax, JSON
    |            +-- Pretty, Traceback
    v
[Terminal]
ANSI-aware rendering
Auto-width detection
Fallback for legacy terms

Self-Hosting & Configuration

# Progress bar with multiple tasks
from rich.progress import Progress
import time

with Progress() as progress:
    task1 = progress.add_task("[cyan]Downloading...", total=100)
    task2 = progress.add_task("[magenta]Processing...", total=100)
    while not progress.finished:
        progress.update(task1, advance=0.9)
        progress.update(task2, advance=0.6)
        time.sleep(0.02)

# Install Rich traceback handler globally
from rich.traceback import install
install(show_locals=True)

# Logging with Rich
import logging
from rich.logging import RichHandler
logging.basicConfig(
    level="INFO", format="%(message)s", datefmt="[%X]",
    handlers=[RichHandler(rich_tracebacks=True)],
)
log = logging.getLogger("rich")
log.info("Hello, Rich!")

Key Features

  • Styled Text — color, bold, italic, underline via BBCode-style markup
  • Tables — auto-sized columns, row/column styles, borders
  • Progress Bars — multi-task progress with ETA, speed, spinners
  • Trees — hierarchical data with unicode connectors
  • Syntax Highlighting — 100+ languages via Pygments
  • Markdown Rendering — GitHub-flavored markdown in the terminal
  • Pretty Tracebacks — colorful, readable exception output
  • Live Updates — dynamic content that redraws in place

Comparison with Similar Tools

Feature Rich Textual colorama blessed tqdm
Style Output Yes Yes (TUI) Basic colors Yes Progress only
Tables Yes Yes No Manual No
Progress Yes Yes No Manual Yes
Markdown Yes Yes No No No
TUI Apps No Yes No Partial No
Windows Yes Yes Yes Partial Yes

FAQ

Q: Rich vs Textual — which should I use? A: Rich for pretty CLI output (logs, tables, tracebacks). Textual for full TUI applications with widgets and event handling. Textual is built on Rich.

Q: Does Rich work on Windows? A: Yes. Rich uses the Windows Console API on older Windows and ANSI escapes on Windows Terminal. All features work cross-platform.

Q: How do I integrate with logging? A: Add RichHandler to your logging config. You get colored log levels, structured keyword args, and rich tracebacks automatically.

Q: Can I use Rich in Jupyter notebooks? A: Yes. Rich detects Jupyter and renders as HTML. Tables, progress bars, and tracebacks all render nicely in notebook cells.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets