--- id: escapism version: "1.1.0" license: MIT license_treatment: permissive maintenance: active --- # escapism — Simple, generic API for escaping strings. License: permissive · Maintenance: active · Downloads: 292.6K/mo ## 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 above — verify before relying. Escapism provides two functions to escape and unescape text using a customizable escape character and safe-character set, plus a lossy slug generator that produces valid Kubernetes-compatible identifiers. 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 pip install escapism uv add escapism poetry add escapism ## Installing escapism 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. 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' Requires Python 3.9 or later. 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_current - Install friction: low - Maintenance: active - Downloads: 292.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags escape unescape strings, text escaping library, safe slug generator, kubernetes valid identifiers, character escaping utility, string sanitization, escape sequences python, string-escaping, kubernetes, slug-generation [View on SkillFed](https://skillfed.io/packages/escapism) · [View on PyPI](https://pypi.org/project/escapism/)