uniseg
Determine Unicode text segmentations
What it is and what it does
uniseg is a pure-Python library for determining Unicode text segmentation boundaries according to the Unicode Standard. It provides functions to identify grapheme cluster boundaries (user-perceived characters that may span multiple code points), word breaks, sentence breaks, and line break opportunities. The package also includes text-wrapping classes for both monospace (console) and proportional (graphical) font environments, making it useful for applications that need to handle text layout and display correctly across different writing systems.
The library implements the Unicode Standard Annex rules for text segmentation without requiring external C libraries or dictionaries. This makes it more portable than alternatives like PyICU, though potentially slower. It supports current Python versions (3.9 through 3.13) and recently achieved a milestone by passing all Unicode breaking tests in version 0.9.0, indicating improved correctness for edge cases.
Use it for:
- Implement proper text wrapping in CLI tools that must respect Unicode line-breaking rules across different scripts.
- Build text editors or word processors that need to identify grapheme cluster boundaries for cursor positioning and text selection.
- Process multilingual text to find word boundaries without relying on language-specific dictionaries.
- Format console output with correct line breaks for Unicode strings containing combining characters or emoji.
- Analyze or segment Unicode text in natural language processing pipelines that require Unicode-aware boundaries.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Determines Unicode text segmentation boundaries—grapheme clusters, words, sentences, and line breaks—using Unicode Standard Annex rules, and provides text wrapping for console and graphical environments.
Yes, if you need Unicode-aware text segmentation in pure Python. The package is stable, has no dependencies, and recently achieved full Unicode test compliance. Install friction is minimal. The aging maintenance status (217 days since last release) is a minor concern for a mature library, but the recent test milestone and current Python version support suggest active stewardship. Avoid if you need maximum performance—PyICU is faster but requires compilation and external libraries.
Install
uniseg on PyPI
pip
pip install uniseguv
uv add unisegpoetry
poetry add unisegInstalling uniseg
Before you install
Low install friction; pure Python with no runtime dependencies. Maintenance status is aging—last release was 217 days ago—but the package recently passed all Unicode breaking tests and supports current Python versions (3.9+).
License in practice
Licensed under MIT (permissive), imposing no restrictions on use, modification, or distribution.
Quickstart
pip install uniseg
import uniseg.graphemecluster
import uniseg.wordbreak
import uniseg.linebreak
for cluster in uniseg.graphemecluster.graphemeclusters('café'):
print(cluster)
for word in uniseg.wordbreak.words('hello world'):
print(word)
Requires Python 3.9 or later.
Verify before relying
- Performance characteristics compared to PyICU or other segmentation libraries for large-scale text processing.
- Whether the package's rule-based grapheme cluster segmentation (reintroduced in 0.9.0) handles all modern Unicode combining sequences correctly.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 217 days since the last release |
| First released | |
| Downloads | 98,360/month — #13,089 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: uniseg-0.10.1-py3-none-any.whl
Keywords: text, unicode
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
segmentsSegments provides Unicode-aware tokenization…
permissive · top 5,000 on PyPI
unicode-segmentation-rsProvides Unicode text segmentation (graphemes,…
unclear · top 15,000 on PyPI
unicodedataplusExtends Python's built-in unicodedata module…
permissive · top 15,000 on PyPI
graphemeProvides string manipulation functions that…
permissive · top 5,000 on PyPI
graphemeuProvides string manipulation functions that…
permissive · top 5,000 on PyPI
semantic-text-splitterSplits long text into semantically meaningful…
permissive · top 15,000 on PyPI
pysbdDetects sentence boundaries in text using…
permissive · top 5,000 on PyPI
segtokSplits Indo-European text into sentences and…
permissive · top 15,000 on PyPI
pyucaImplements the Unicode Collation Algorithm to…
permissive · top 15,000 on PyPI
confusable-homoglyphsDetects Unicode homoglyphs and mixed-script…
permissive · top 5,000 on PyPI