ansicolors
ANSI colors for Python
What it is and what it does
ansicolors is a lightweight library that wraps strings with ANSI escape sequences to add foreground color, background color, and text styling (bold, underline, etc.) for display in terminal emulators. It offers multiple ways to specify colors: 8 basic ANSI names (black, red, green, yellow, blue, magenta, cyan, white), 256-color xterm palette by integer index (0-255), or 24-bit RGB via tuple, CSS color name, hex string, or RGB notation. The library also provides utility functions to strip ANSI codes from styled strings and compute their effective length.
The package has no runtime dependencies and installs as a pure Python wheel, making it trivial to add to any project. However, it is abandoned—the last release was in 2017, and the repository has not been updated since 2022. While the core functionality remains stable and works on modern Python versions, no maintenance or fixes will be forthcoming. Terminal support for ANSI codes varies widely; the library will emit the codes regardless, but not all terminals render all colors and styles accurately.
Use it for:
- Colorize CLI tool output (error messages in red, success in green) for better user readability.
- Highlight specific log entries or warnings in terminal-based monitoring or debugging scripts.
- Create styled prompts or status messages in interactive command-line applications.
- Generate colored output for test runners or build tool summaries to distinguish pass/fail/skip states.
- Add visual emphasis to data dumps or formatted text in terminal-based data inspection tools.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Embeds ANSI color and style codes into Python strings for colored terminal output, supporting 8 basic colors, 256-color xterm palette, 24-bit RGB, and CSS color names.
Yes, if you need simple ANSI coloring in a CLI tool and accept that the package will not be maintained. The library is stable, dependency-free, and widely used (top 5000 on PyPI). Do not use it if you require active maintenance, Python 2 support, or advanced terminal control beyond basic colors and styles. For new projects, consider whether a more actively maintained alternative better suits your risk tolerance.
Install
ansicolors on PyPI
pip
pip install ansicolorsuv
uv add ansicolorspoetry
poetry add ansicolorsInstalling ansicolors
Before you install
Installation is frictionless—a pure Python wheel with no runtime dependencies. However, the package is abandoned: last release was 2017-06-02, over 3360 days ago, with no commits since 2022-08-18. It still works for basic use but will not receive bug fixes or updates.
License in practice
Licensed under ISC (permissive), which allows commercial and private use with minimal restrictions. No notable licensing barriers to adoption.
Quickstart
pip install ansicolors
from ansicolors import color
print(color('my string', fg='blue'))
print(color('some text', fg='red', bg='yellow', style='underline'))
Verify before relying
- Whether the package's Python 2 support (2.6, 2.7) and older Python 3 versions (3.3–3.6) remain relevant for your use case, given Python 2 EOL.
- Terminal/device compatibility: the description notes fragmented ANSI support across terminals—verify your target environment handles the colors and styles you need.
Package facts
| License | ISC (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 3,360 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 12,803,460/month — #1,304 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ansicolors-1.1.8-py2.py3-none-any.whl
Keywords: ASNI, color, style, console
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
ansiProvides ANSI escape codes for cursor movement…
permissive · top 15,000 on PyPI
ansiconEnables ANSI color and style codes in Windows…
copyleft · top 15,000 on PyPI
ansiwrapWraps and formats text while correctly handling…
permissive · top 5,000 on PyPI
coloredColored provides ANSI/VT100 escape sequences…
permissive · top 5,000 on PyPI
stySty provides a simple, customizable string…
permissive · top 15,000 on PyPI
tcolorpyApplies ANSI true color and text styles (bold,…
permissive · top 5,000 on PyPI
ansi2htmlConverts terminal output with ANSI color codes…
copyleft · top 5,000 on PyPI
ansimarkupAnsimarkup converts XML-like markup tags into…
permissive · top 15,000 on PyPI
simple-colorsAdds colored and styled text output to terminal…
unclear · top 15,000 on PyPI
colorclassProvides ANSI color text output for console…
permissive · top 5,000 on PyPI