ansi
ANSI cursor movement and graphics
What it is and what it does
ANSI is a small library that wraps ANSI escape codes—the standard sequences terminals use to move the cursor, change text color, apply effects like bold or underline, and control other display attributes. It lets you build styled terminal output by composing color and effect objects, either as a sequence of strings to join or through a functional syntax where colors wrap text as callables.
The package supports standard ANSI colors (foreground and background), text effects (reset, bold, etc.), and 256-color RGB mode for finer color control. It offers both British and American English module names (ansi.colour and ansi.color). With only typing-extensions as a dependency and a pure-Python wheel, it installs with minimal friction and works on any Python 3.6+ environment with a terminal that understands ANSI codes.
Use it for:
- Add colored and styled output to CLI tools and scripts without external dependencies.
- Build terminal-based user interfaces with cursor positioning and text effects.
- Highlight errors, warnings, and status messages in console applications.
- Generate colored log output for debugging and monitoring scripts.
- Create visually distinct sections in terminal reports or data displays.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides ANSI escape codes for cursor movement and text styling (colors, effects) in terminal output, with support for 256 RGB colors and both British and American English naming.
Yes, if you need ANSI terminal styling in a CLI tool or script. The package is lightweight, has no security issues, and carries a permissive license. Its dormant maintenance is not a blocker for stable, narrow functionality like ANSI code generation, but verify that the codes work reliably with your target terminals before relying on it for critical output.
Install
ansi on PyPI
pip
pip install ansiuv
uv add ansipoetry
poetry add ansiInstalling ansi
Before you install
Low friction: pure Python wheel with only typing-extensions as a runtime dependency. Dormant maintenance (last commit 2024-01-22, 935 days since release), but repository is not archived and has seen recent activity.
License in practice
MIT License permits commercial and private use with minimal restrictions; you may use, modify, and distribute the package freely provided you retain the license notice.
Quickstart
pip install ansi
from ansi.colour import fg, bg
from ansi.colour.fx import reset
msg = (bg.red, fg.yellow, 'Hello world!', reset)
print(''.join(map(str, msg)))
Requires Python 3.6 or later; terminal must support ANSI escape sequences for colors and effects to render.
Verify before relying
- Whether the package is actively maintained or if dormancy signals upcoming deprecation
- Compatibility with modern terminal emulators and whether all ANSI codes work reliably across platforms
Package facts
| License | MIT License (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing-extensions |
| Maintenance | dormant — 935 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 103,553/month — #12,799 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ansi-0.3.7-py3-none-any.whl
Tags
More Terminals packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
richRich renders styled text, tables, progress…
permissive · top 100 on PyPI
coloramaColorama makes ANSI escape sequences for…
permissive · top 100 on PyPI
wcwidthMeasures the displayed width of Unicode strings…
permissive · top 1,000 on PyPI
ptyprocessRun a subprocess in a pseudo terminal (pty) and…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
ansicolorsEmbeds ANSI color and style codes into Python…
permissive · top 5,000 on PyPI
climageConverts images to ANSI escape code sequences…
permissive · top 15,000 on PyPI
coloredColored provides ANSI/VT100 escape sequences…
permissive · top 5,000 on PyPI
cursorHides or shows the terminal cursor in Python…
copyleft · top 15,000 on PyPI
pansiPansi provides a clean interface for rendering…
permissive · top 15,000 on PyPI
ansi2htmlConverts terminal output with ANSI color codes…
copyleft · top 5,000 on PyPI
terminaltexteffectsRenders animated visual effects for text…
permissive · top 15,000 on PyPI
strip-ansiRemoves ANSI escape sequences (color codes,…
unclear · top 15,000 on PyPI
colorfulColorful applies ANSI color and text styling to…
permissive · top 5,000 on PyPI
ansimarkupAnsimarkup converts XML-like markup tags into…
permissive · top 15,000 on PyPI