Rich

14.3.3 · active · verified Sat Mar 28

Rich is a Python library for writing styled text, tables, progress bars, syntax-highlighted code, Markdown, and tracebacks to the terminal. It works on Linux, macOS, and Windows (true color on new Windows Terminal; 16-color on classic cmd.exe). Current version is 14.3.3 (released 2026-02-19); the project follows an active release cadence with frequent patch and minor releases under the Textualize organization.

Warnings

Install

Imports

Quickstart

Demonstrate Console, markup, Table, Progress, RichHandler, and Syntax in one runnable script.

import logging
import time

from rich.console import Console
from rich.logging import RichHandler
from rich.markup import escape
from rich.progress import track
from rich.syntax import Syntax
from rich.table import Table

# -- Console & markup --
console = Console()
console.print("[bold magenta]Rich[/bold magenta] is working! :tada:")

# -- Safe interpolation of untrusted strings --
user_input = "[blink]injected[/blink]"
console.print(f"Hello, {escape(user_input)}!")

# -- Table --
table = Table(title="Languages")
table.add_column("Name", style="cyan")
table.add_column("Paradigm", style="green")
table.add_row("Python", "Multi-paradigm")
table.add_row("Haskell", "Functional")
console.print(table)

# -- Syntax highlighting --
code = "def greet(name):\n    return f'Hello, {name}!'"
syntax = Syntax(code, "python", theme="monokai", line_numbers=True)
console.print(syntax)

# -- Progress bar --
for _ in track(range(5), description="Processing..."):
    time.sleep(0.1)

# -- stdlib logging integration --
logging.basicConfig(
    level="INFO",
    format="%(message)s",
    datefmt="[%X]",
    handlers=[RichHandler()],
)
log = logging.getLogger("rich")
log.info("All done.")

view raw JSON →