Skip to main content

Ansistrip

ansistrip banner

Mini-lib to strip ANSI Escape codes from a string.

CI PyPI version Python versions License: MIT DeepWiki

Installation

Install with uv:

uv add ansistrip

Usage

In [1]: import ansistrip

In [2]: text = "\x1b[1m\x1b[38;5;10mtest\x1b[0m"

In [3]: ansistrip.ansi_strip(text)
Out[3]: 'test'

It also handles 8-bit C1 controls, plain ESC sequences such as ESC ( B or ESC c, and control strings such as terminal titles and OSC 8 hyperlinks:

In [4]: ansistrip.ansi_strip("\x1b]0;my title\x07hello")
Out[4]: 'hello'

In [5]: ansistrip.ansi_strip("\x1b]8;;https://example.com\x1b\\link\x1b]8;;\x1b\\")
Out[5]: 'link'

Non-ASCII text is left untouched:

In [6]: ansistrip.ansi_strip("\x1b[31mÉXITO: configuración\x1b[0m")
Out[6]: 'ÉXITO: configuración'

Development

uv sync
uv run pytest

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ansistrip-0.3.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ansistrip-0.3.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file ansistrip-0.3.0.tar.gz.

File metadata

  • Download URL: ansistrip-0.3.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ansistrip-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9bba892b11cf30ce57cfef1821cd9e9318ee0c6e8182fbca230bc2834ddef71f
MD5 7b582d0edace6713d1dc813a03a4afc9
BLAKE2b-256 683d2075d07cd2a123be64d8ef4bee2205f3b3b0d7083e49499bcdaf53b5aeb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ansistrip-0.3.0.tar.gz:

Publisher: release.yml on carlosplanchon/ansistrip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ansistrip-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ansistrip-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ansistrip-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a35214c866eedd68d0d464dbb1f21781f4dfd2183220403835769d505f940dd
MD5 0920aa99e7f9cb21ec2982b048558ef9
BLAKE2b-256 f53498de7c7e9d31709bf9f36f942b814674f0e068d4c718c7ad08de03864b2c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ansistrip-0.3.0-py3-none-any.whl:

Publisher: release.yml on carlosplanchon/ansistrip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page