strip-ansi
Strip ANSI escape sequences from a string
What it is and what it does
strip-ansi is a minimal utility that removes ANSI escape sequences—the control codes terminals use for colors, bold, underline, and other text formatting—from strings. It takes a string containing these codes and returns the plain text content. The package has no runtime dependencies and installs quickly.
It is typically used when you need to log, store, or process terminal output that includes color codes but you want only the readable text. Common scenarios include cleaning up colored CLI output for storage in files, parsing terminal logs, or preparing text for analysis where formatting codes would interfere.
Use it for:
- Strip color codes from CLI tool output before writing to a log file or database.
- Clean up terminal output captured from colored command-line utilities for text processing.
- Prepare colored terminal text for analysis or comparison where ANSI codes would cause false mismatches.
- Remove formatting codes from captured pytest or test runner output for plain-text reporting.
- Sanitize colored output from third-party CLI tools before displaying in a non-terminal context.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Removes ANSI escape sequences (color codes, formatting directives) from strings, leaving plain text.
Yes, if you need to strip ANSI codes from strings and accept dormant maintenance. The package is simple, dependency-free, and has no known vulnerabilities. However, verify the license before use, and be aware that no updates have been released since June 2020—if future Python versions introduce breaking changes to string handling or ANSI standards, this package may not adapt.
Install
strip-ansi on PyPI
pip
pip install strip-ansiuv
uv add strip-ansipoetry
poetry add strip-ansiInstalling strip-ansi
Before you install
Low install friction; no runtime dependencies. Maintenance is dormant—last release June 2020, no updates since, though the repository remains active with a recent commit in December 2024.
License in practice
License status is unclear; the package metadata contains no SPDX identifier or raw license text. Verify the actual license before using in proprietary or copyleft-sensitive contexts.
Quickstart
pip install strip_ansi
from strip_ansi import strip_ansi
result = strip_ansi("\033[38mLorem ipsum\033[0m")
print(result) # Output: Lorem ipsum
Requires Python 3.6 or later; author notes uncertainty about compatibility with Python 2 or versions below 3.6.
Verify before relying
- Whether the package is actively maintained or if dormancy signals abandonment risk for future Python versions.
- Actual license terms—metadata does not declare one, so check the repository directly.
- Whether ANSI stripping handles all modern terminal escape sequences or only a subset.
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.6,<4.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 2,246 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 176,460/month — #10,241 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: strip_ansi-0.1.1-py3-none-any.whl
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
ansi2htmlConverts terminal output with ANSI color codes…
copyleft · top 5,000 on PyPI
ansi2txtConverts ANSI escape sequences (color codes,…
unclear · top 15,000 on PyPI
ansiProvides ANSI escape codes for cursor movement…
permissive · top 15,000 on PyPI
coloramaColorama makes ANSI escape sequences for…
permissive · top 100 on PyPI
ansiwrapWraps and formats text while correctly handling…
permissive · top 5,000 on PyPI
pansiPansi provides a clean interface for rendering…
permissive · top 15,000 on PyPI
coloredColored provides ANSI/VT100 escape sequences…
permissive · top 5,000 on PyPI
strip-hintsStrips type hints from Python source code while…
unclear · top 5,000 on PyPI
demojidemoji finds and removes emojis from text,…
permissive · top 15,000 on PyPI
pretty-errorsReformats Python exception tracebacks with…
permissive · top 15,000 on PyPI