A library for Unicode normalization (NFC, NFD, NFKC, NFKD) independent of Python's core Unicode database.
Maintained. Last release 2 months ago, commits in 1 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install pyunormalizepyunormalize
The pyunormalize package is a pure-Python, zero-dependency implementation of the Unicode normalization algorithm.
It supports the four standard Unicode normalization forms:
- NFC
- NFD
- NFKC
- NFKD
The package uses generated lookup tables derived from the Unicode Character Database (UCD) for Unicode 18.0.0, released in September 2026. It is therefore independent of the unicodedata module and the specific Unicode database version bundled with the Python runtime on which it is installed.
All four normalization forms are tested against the official Unicode NormalizationTest.txt test file.
Requirements
Python 3.9 or newer.
Installation
Install the package with:
pip install pyunormalize
Upgrade to the latest version with:
pip install --upgrade pyunormalize
Public API
The public API exposes the four normalization functions and a generic dispatcher:
from pyunormalize import NFC, NFD, NFKC, NFKD, normalize
It also exposes constants for the Unicode version in use:
from pyunormalize import UCD_VERSION, UNICODE_VERSION
Note that UCD_VERSION and UNICODE_VERSION are aliases referring to the same version string ('18.0.0').
Usage examples
Below are practical examples illustrating how to normalize Unicode strings using either dedicated functions or the generic dispatcher.
Dedicated functions
Use the convenience functions NFC, NFD, NFKC, or NFKD for direct normalization:
from pyunormalize import NFC, NFD, NFKC, NFKD
text = "désaffiliât"
assert text == NFC(text)
def hex_repr(string):
return " ".join([f"{ord(c):04X}" for c in string])
print(f"NFD : {hex_repr(NFD(text))}")
print(f"NFKD : {hex_repr(NFKD(text))}")
print(f"NFC : {hex_repr(NFC(text))}")
print(f"NFKC : {hex_repr(NFKC(text))}")
Output:
NFD : 0064 0065 0301 0073 0061 FB03 006C 0069 0061 0302 0074
NFKD : 0064 0065 0301 0073 0061 0066 0066 0069 006C 0069 0061 0302 0074
NFC : 0064 00E9 0073 0061 FB03 006C 0069 00E2 0074
NFKC : 0064 00E9 0073 0061 0066 0066 0069 006C 0069 00E2 0074