grapheme
Unicode grapheme helpers
What it is and what it does
grapheme is a Python library for working with grapheme clusters—the user-perceived characters that the Unicode Standard defines—rather than raw Unicode code points. Standard Python string functions treat each Unicode code point as a separate unit, which breaks strings containing combining marks (like underlines or accents), emoji with skin-tone modifiers, Korean Hangul, and other multi-codepoint sequences. This library implements the Unicode default rules for extended grapheme clusters and provides functions like `length()`, `substr()`, `slice()`, and `contains()` that operate on graphemes instead.
The package is useful when you need to count, truncate, or format text the way users actually see it—for example, when building text-based tables in monospaced fonts or ensuring that user input doesn't corrupt multi-codepoint characters. Performance scales linearly with string length, and the library is designed for short strings or the beginning of long strings; the documentation notes that grapheme calculation is notably slower than counting code points and recommends using standard Python functions when performance is prioritized over correctness.
Use it for:
- Count user-perceived character length in strings with combining marks or emoji modifiers without overcounting code points.
- Truncate or slice text at user-perceived boundaries to avoid splitting multi-codepoint characters and corrupting display.
- Format text-based tables or monospaced output by actual visible character width rather than Unicode code point count.
- Validate user input length constraints based on what users actually see rather than internal Unicode representation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides string manipulation functions that work with grapheme clusters—user-perceived characters—rather than individual Unicode code points, enabling correct length calculations and slicing for strings with combining marks, emoji modifiers, and other multi-codepoint characters.
No. The package is abandoned (last release 2020-03-07, last commit 2022-03-21) and carries high installation friction due to compilation requirements. While it solves a real problem—correct grapheme handling—the lack of maintenance means compatibility issues with newer Python versions or Unicode standards will not be fixed. Consider it only if you are locked into an older Python environment and have no alternative; otherwise, seek an actively maintained grapheme library or implement grapheme logic inline if your use case is narrow.
Install
grapheme on PyPI
pip
pip install graphemeuv
uv add graphemepoetry
poetry add graphemeInstalling grapheme
Before you install
Installation requires compilation (high friction). The package is abandoned—last release was 2020-03-07, last commit 2022-03-21—and classifiers indicate Alpha status. No runtime dependencies, but no active maintenance means security or compatibility issues will not be addressed.
License in practice
MIT license is permissive and poses no restrictions on use, modification, or distribution.
Quickstart
pip install grapheme
import grapheme
string = 'u̲n̲d̲e̲r̲l̲i̲n̲e̲d̲'
print(grapheme.length(string)) # 10 (user-perceived characters)
print(grapheme.substr(string, 0, 3)) # 'u̲n̲d̲'
Requires compilation during installation; no explicit Python version requirement stated, but classifiers list support through Python 3.8.
Verify before relying
- Whether the package works reliably with Python versions beyond 3.8 (classifiers stop there, but no explicit upper bound is documented).
- Current Unicode Standard Annex #29 compliance status—the package targets Unicode 13.0.0, but no statement on whether later Unicode versions are supported.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | abandoned — 2,351 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,192,529/month — #4,237 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: grapheme-0.6.0.tar.gz
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
graphemeuProvides string manipulation functions that…
permissive · top 5,000 on PyPI
unisegDetermines Unicode text segmentation…
permissive · top 15,000 on PyPI
unicode-segmentation-rsProvides Unicode text segmentation (graphemes,…
unclear · top 15,000 on PyPI
emojiConverts between emoji characters and their…
permissive · top 1,000 on PyPI
anyasciiConverts Unicode text to ASCII-only equivalents…
permissive · top 5,000 on PyPI
unicodedataplusExtends Python's built-in unicodedata module…
permissive · top 15,000 on PyPI
confusablesDetects and matches words that appear identical…
permissive · top 15,000 on PyPI
demojidemoji finds and removes emojis from text,…
permissive · top 15,000 on PyPI
segmentsSegments provides Unicode-aware tokenization…
permissive · top 5,000 on PyPI
confusable-homoglyphsDetects Unicode homoglyphs and mixed-script…
permissive · top 5,000 on PyPI