| Crates.io | fast-strip-ansi |
| lib.rs | fast-strip-ansi |
| version | 0.3.0 |
| created_at | 2025-08-25 17:54:18.970606+00 |
| updated_at | 2025-09-15 22:12:49.884122+00 |
| description | A performance-optimized, low-allocation ANSI escape sequence stripper |
| homepage | |
| repository | https://github.com/mmastrac/vt-push-parser |
| max_upload_size | |
| id | 1809884 |
| size | 14,041 |
A performance-optimized ANSI escape sequence stripper.
Full VT-100/ANSI support.
No startup cost for regex compilation.
let input = b"Hello, world!\x1b[31mHello, world!\x1b[0m";
let output = strip_ansi_string(input);
fast-strip-ansi is correct and secure. It contains a true VT-100/ANSI state
machine which handles corner cases not handled by other crates.
fast-strip-ansi the fastest and most correct library for stripping ANSI escape
sequences.
Note that fast-strip-ansi has wider support for ANSI escape sequences than
most crates but is still the fastest option.
It is significantly faster than strip-ansi and strip-ansi-escapes in all
modes.
xychart
title "Performance"
x-axis [fast-strip-ansi, fast-strip-ansi-callback, strip-ansi, strip-ansi-escapes]
y-axis "Time (in µs)" 0 --> 100
bar [22.12, 11.26, 39.05, 292.5]
bar [11.89, 6.841, 19.21, 277.4]
Raw performance data:
from cargo bench on an M3 MacBook Pro
0 suffix means no ansi content, 100 means significant ansi content
| comparison | fastest | median |
|---|---|---|
| fast_strip_ansi_crate_0 | 6.54 µs | 6.937 µs |
| fast_strip_ansi_crate_100 | 18.7 µs | 19.14 µs |
| fast_strip_ansi_crate_bytes_0 | 6.624 µs | 6.707 µs |
| fast_strip_ansi_crate_bytes_100 | 10.83 µs | 10.95 µs |
| fast_strip_ansi_crate_callback_0 | 6.333 µs | 6.416 µs |
| fast_strip_ansi_crate_callback_100 | 10.37 µs | 10.66 µs |
| strip_ansi_crate_0 | 15.33 µs | 15.95 µs |
| strip_ansi_crate_100 | 23.54 µs | 26.47 µs |
| strip_ansi_escapes_crate_0 | 235.9 µs | 257.9 µs |
| strip_ansi_escapes_crate_100 | 241.8 µs | 269.1 µs |
Crate versions:
| crate | version |
|---|---|
| fast-strip-ansi | latest |
| strip-ansi | 0.1.0 |
| strip-ansi-escapes | 0.2.1 |