gitmyhub

rich

Python ★ 57k updated 23d ago

Rich is a Python library for rich text and beautiful formatting in the terminal.

A pure-Python library that adds color, formatted tables, animated progress bars, and syntax highlighting to terminal output with minimal code, replacing plain print statements.

Pythonsetup: easycomplexity 2/5

Rich is a Python library that makes terminal output beautiful and informative. The default terminal experience in Python — plain white text, no structure — is hard to read for complex data, long logs, or progress-heavy scripts. Rich solves this by giving your terminal programs color, layout, and formatting with minimal extra code.

The way it works is straightforward: Rich provides a drop-in replacement for Python's built-in print function that accepts markup tags similar to HTML. Writing [bold red]warning[/bold red] renders that word in bold red in the terminal. Beyond simple text styling, Rich can render formatted tables where rows and columns line up cleanly, animated progress bars that update in place to show how much of a long task is done, syntax-highlighted source code with proper color coding for the language, Markdown documents rendered with headings and emphasis, and exception tracebacks that display the local variable values at each stack frame so debugging is much easier. It also includes an inspect function that pretty-prints any Python object showing its attributes and methods in a structured way.

Rich adapts to the terminal's capabilities: it renders 24-bit color where available, falls back gracefully on older terminals, and also works in Jupyter notebooks without any configuration. It supports Windows, macOS, and Linux.

You would use Rich any time you are building a command-line tool and want the output to be readable — for progress reporting during a long computation, for printing configuration data or API responses in a structured way, for improving developer tools and scripts that other people will run, or for making your own debugging output easier to scan. The tech stack is pure Python 3, installable via pip, with no external dependencies.

Where it fits