Unicode guide
Unicode Normalization Explained: NFC, NFD, NFKC, NFKD
Unicode normalization converts strings into defined forms so text with equivalent representations can be compared consistently. The choice between canonical and compatibility forms determines how much information is preserved.
Why identical-looking strings can differ
The letter é can be encoded as the precomposed U+00E9 or as U+0065 followed by U+0301. These sequences can render alike while a naive code-point-by-code-point comparison treats them as different strings.
Normalization puts canonically equivalent sequences into a consistent form. This prevents a composed-versus-decomposed difference from silently breaking exact comparison or search.
Canonical and compatibility forms
NFC applies canonical decomposition and then composes where possible, producing a canonical composed form. NFD keeps the canonical decomposed form instead.
NFKC and NFKD additionally apply compatibility decomposition. NFKC then composes the result, while NFKD leaves it decomposed. Compatibility processing can fold the fi ligature at U+FB01 to fi, full-width forms to ASCII, and styled mathematical letters to plain letters.
fi A 𝐁fi A BGlyphSift's NFKC result folds the ligature, full-width A, and Mathematical Bold B to compatibility equivalents.
Choose the form for the job
NFC is a practical choice for storage and comparison when compatibility distinctions should remain. It makes canonical equivalents consistent without deliberately folding decorative or width variants to plain text.
NFKC is useful for loose search and matching, but it can destroy intended appearance. A bold or fancy name may become plain letters, so compatibility normalization is the wrong choice when preserving decorative text matters.
Primary standards