escapism
Simple, generic API for escaping strings.
Decision gist · record as of 2026-08-14
Yes. Escapism is a stable, dependency-free utility with a clear, minimal API and active maintenance. It's well-suited for any project needing string escaping or Kubernetes-compatible slug generation. No known vulnerabilities, permissive license, and low install friction make it a safe choice.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later.
- Low install friction with no runtime dependencies.
- Actively maintained as of 2026-08-01 with a stable release history since 2015.
License · maintenance · safety
MIT (permissive) — MIT license permits use in proprietary and open-source projects with minimal restrictions; attribution required.
last release 2025-12-11 (246 days) · last repo commit 2026-08-01 · 3 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 292,593 downloads/mo, #7,961 on PyPI
Alternatives
Verify before relying
import escapism
escaped = escapism.escape('string to escape')
# 'string_20to_20escape'
original = escapism.unescape(escaped)
# For Kubernetes-compatible slugs:
slug = escapism.safe_slug('my-identifier')
# 'my-identifier'- Whether safe_slug's trim-and-hash behavior (appending hash after '---') is suitable for all use cases beyond Kubernetes.
- Performance characteristics when escaping very large strings or with large safe-character sets.
What it is and what it does
Escapism is a lightweight string escaping library that converts unsafe characters into escape sequences using a configurable escape character (default: underscore). It provides two main APIs: a reversible escape/unescape pair for general text escaping, and a lossy slug generator designed for Kubernetes resource naming that enforces strict validity rules (lowercase, alphanumeric plus hyphens, length 1–63, starting with a letter). The slug function is useful when you need a valid identifier but don't need to recover the original string; it applies hashing to ensure uniqueness when the input violates validity constraints.
The package has no runtime dependencies and installs as a pure Python wheel. It's actively maintained and used in production by JupyterHub-related projects. The API is minimal—just two functions with optional arguments for customizing the escape character and safe-character set—making it straightforward to integrate into any text-processing pipeline that needs controlled character escaping or identifier generation.
Use it for
- Escape special characters in strings for use in URLs, filenames, or configuration keys while preserving reversibility.
- Generate valid Kubernetes object names and label values from arbitrary user input with automatic hashing for collision avoidance.
- Sanitize usernames or identifiers to meet strict naming constraints (length, character set, start/end rules) in distributed systems.
- Encode text for storage in systems with restricted character sets while maintaining the ability to decode it later.
- Create URL-safe slugs from user-provided strings for web applications or APIs.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Escapism is a stable, dependency-free utility with a clear, minimal API and active maintenance. It's well-suited for any project needing string escaping or Kubernetes-compatible slug generation. No known vulnerabilities, permissive license, and low install friction make it a safe choice.
Install
escapism on PyPI
Before you install
Low install friction with no runtime dependencies. Actively maintained as of 2026-08-01 with a stable release history since 2015. Requires Python 3.9 or later.
Requires Python 3.9 or later.
License in practice
MIT license permits use in proprietary and open-source projects with minimal restrictions; attribution required.
Quickstart
import escapism
escaped = escapism.escape('string to escape')
# 'string_20to_20escape'
original = escapism.unescape(escaped)
# For Kubernetes-compatible slugs:
slug = escapism.safe_slug('my-identifier')
# 'my-identifier'
Verify before relying
- Whether safe_slug's trim-and-hash behavior (appending hash after '---') is suitable for all use cases beyond Kubernetes.
- Performance characteristics when escaping very large strings or with large safe-character sets.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 246 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 292,593 / month, #7,961 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Science/ResearchIntended Audience :: System AdministratorsProgramming Language :: PythonProgramming Language :: Python :: 3 |
Evidence: escapism-1.1.0-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 › “escape unescape strings”
- escapismEscapism provides two functions to escape and unescape text using a…
- shellescapeProvides a `quote()` function that shell-escapes Python strings to…
- strip-ansiRemoves ANSI escape sequences (color codes, formatting directives)…
Give your agent the search over MCP, or paste the wish link into any chat.
More Text Processing packages
A drop-in replacement for Python's standard `re` module that adds advanced regex features like nested sets, fuzzy matching, lookaround in conditionals, and full Unicode case-folding while maintaining backward compatibility.
pyparsing provides a library for building text parsers directly in Python code using composable grammar classes, handling quoted strings, whitespace variation, and embedded comments without regex or lex/yacc.
Install it if you need to parse text or define grammars programmatically.
fonttools manipulates font files in multiple formats (TrueType, OpenType, AFM, Type 1, Mac-specific) and includes TTX, a tool to convert fonts to and from XML text format.
Install it if you need to read, write, or manipulate fonts programmatically or via the TTX command-line tool.
Docutils converts plaintext documentation in reStructuredText format into multiple output formats including HTML, XML, and LaTeX using a modular processing system.
RapidFuzz provides fast fuzzy string matching using Levenshtein Distance and related metrics, implemented mostly in C++ with Python bindings for rapid similarity scoring and approximate string matching.
Install it if you need fuzzy string matching; it's a solid replacement for FuzzyWuzzy with better licensing and performance.
tinycss2 parses CSS strings into token and block objects, and generates CSS strings from those objects, following the CSS Syntax Level 3 specification without enforcing specific properties or values.
Install it if your project requires CSS tokenization or syntax manipulation.
See also slugify · Unidecode · python-slugify · MarkupSafe · anyascii · random-slugs · unicode-slugify · django-autoslug · coolname · sqids