Unicode NFC vs NFD: what is the difference?

See why two strings can look identical while containing different code points.

6 min read•Updated

Quick answer: NFC uses precomposed characters when Unicode provides them, while NFD separates a base letter from its combining marks. They often render identically but can differ in code-point count, byte length, and direct string comparison.

Illustration of a Unicode character in composed and decomposed forms

One visible letter, two encodings

In NFC, Vietnamese “ế” is usually U+1EBF. In NFD it can be stored as e U+0065, combining circumflex U+0302, and combining acute U+0301. A browser renders the sequence as one visible letter.

This difference often appears when text moves between operating systems, keyboards, databases, and libraries. A byte-for-byte comparison can fail even when the words look the same.

Same appearance, different code points

Before

NFC: ế → U+1EBF

After

NFD: e + ◌̂ + ◌́ → U+0065 U+0302 U+0301

Which form should you use?

NFC is a practical default for web content, names, search fields, and general storage. NFD is useful when an application must inspect combining marks separately. NFKC and NFKD also fold compatibility characters, so they can change presentation meaning and require more care.

A safe repair workflow

Keep the original, inspect its code points, normalize a copy to NFC, and compare again. Normalize consistently when data enters a system rather than applying scattered fixes later. The Unicode normalizer on this site shows the code points before and after the change.

Why identical-looking strings are not equal in JavaScript

Compare code points before removing accents or changing letters. For canonically equivalent strings, applying String.normalize("NFC") to both sides makes the representation consistent. NFC does not remove whitespace or resolve every similar-looking character.

NFC vs NFD JavaScript comparison

Before

const a = "ế";
const b = "e\u0302\u0301";
a === b; // false

After

a.normalize("NFC") === b.normalize("NFC"); // true
Array.from(b).length; // 3 code points

Normalize before removing duplicate lines

A list containing both NFC and NFD can retain duplicate-looking names after an exact comparison. Normalize each line on a copy, decide whitespace and case rules separately, then keep the first occurrence. Preserve accents when accented names must remain distinct.

If NFC does not make two strings equal, inspect for U+00A0, U+200B or a letter from another script. Repeating normalization does not remove these differences.

Frequently asked questions

Does Unicode normalization remove accents?

NFC and NFD preserve accents. They only change how the text is encoded.

Why does string length change?

NFD can use several code points for one visible grapheme, so code-point and UTF-16 lengths may increase.

References