ansiwrap
textwrap, but savvy to ANSI colors and styles
Decision gist · record as of 2026-08-14
Yes. The package solves a real problem (textwrap + ANSI codes) with no dependencies, permissive licensing, and active maintenance. It's small, focused, and widely downloaded. Install it if you're building terminal UIs or CLI tools with colored output that need proper text wrapping.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: pure Python wheel with no runtime dependencies.
- Maintenance is active with recent commits, though the latest release was in 2019.
License · maintenance · safety
Apache License 2.0 (permissive) — Apache License 2.0 is permissive; you can use this in commercial and proprietary projects with minimal restriction.
last release 2019-01-23 (2760 days) · last repo commit 2026-07-07 · 22 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,218,912 downloads/mo, #4,202 on PyPI
Alternatives
Verify before relying
pip install ansiwrap
from ansiwrap import wrap, fill, shorten, ansilen, strip_color
lines = wrap('colored text', width=20)
filled = fill('colored text', width=20)
shortened = shorten('colored text', 20, placeholder='...')- Whether the package handles all ANSI escape sequences or only color/style codes
- Performance characteristics on very long strings or high-volume wrapping operations
- Exact Python version support beyond the classifiers listed (2.6, 2.7, 3.3-3.7)
What it is and what it does
ansiwrap extends Python's standard textwrap module to handle ANSI escape sequences correctly. When you wrap or fill text containing ANSI color codes, textwrap miscalculates line length because it counts the raw bytes of invisible control codes. ansiwrap strips those codes during measurement, so wrapped lines respect actual display width, not byte length.
The package provides wrap(), fill(), and shorten() functions mirroring textwrap's API, plus utility functions like ansilen() to measure visible text length and strip_color() to remove codes entirely. It has no runtime dependencies and works across Python 2 and 3, making it straightforward to drop into terminal UI code or CLI tools that use colored output.
Use it for
- Format colored log output to fit terminal width without breaking lines due to invisible codes
- Wrap help text in CLI tools that use ANSI colors for emphasis without miscounting line length
- Truncate colored status messages to a fixed display width in terminal dashboards
- Process multi-line colored text and reflow it to new widths while preserving styling
- Strip ANSI codes from colored strings when you need plain text for logging or storage
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package solves a real problem (textwrap + ANSI codes) with no dependencies, permissive licensing, and active maintenance. It's small, focused, and widely downloaded. Install it if you're building terminal UIs or CLI tools with colored output that need proper text wrapping.
Install
ansiwrap on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Maintenance is active with recent commits, though the latest release was in 2019.
License in practice
Apache License 2.0 is permissive; you can use this in commercial and proprietary projects with minimal restriction.
Quickstart
pip install ansiwrap
from ansiwrap import wrap, fill, shorten, ansilen, strip_color
lines = wrap('colored text', width=20)
filled = fill('colored text', width=20)
shortened = shorten('colored text', 20, placeholder='...')
Verify before relying
- Whether the package handles all ANSI escape sequences or only color/style codes
- Performance characteristics on very long strings or high-volume wrapping operations
- Exact Python version support beyond the classifiers listed (2.6, 2.7, 3.3-3.7)
Package facts
| License | Apache License 2.0 permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 2,760 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,218,912 / month, #4,202 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python ModulesTopic :: Text ProcessingTopic :: Text Processing :: Filters |
Evidence: ansiwrap-0.8.4-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “ANSI color text wrapping”
- ansiwrapWraps and formats text while correctly handling ANSI color and style…
- coloramaColorama makes ANSI escape sequences for colored terminal text work…
- ansiconEnables ANSI color and style codes in Windows console output by…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also ansicolors · textwrap3 · colored · crayons · termcolor · strip-ansi · ansi · colorful · enrich · treetable