How to normalize a Unicode string to NFC

By

Normalize a string to NFC in the browser and read the code points before and after. The page also shows NFD, NFKC, and NFKD. The string is not put in the URL.

Free toolThis tutorial uses the Unicode Normalization. It runs in your browser, so open it in another tab and follow along.

NFC is the composed form. The word café can be U+00E9, one code point for é. The same word can be the letter e plus a combining acute, U+0301. They look the same. They compare as different until you normalize them.

The Unicode normalization converter runs String.prototype.normalize in the browser. The string stays on the page. The form can live in the URL. The string does not.

Normalize the sample

  1. Open the Unicode normalization converter.
  2. Click Load sample. The sample is café written as e plus U+0301.
  3. Leave the form on NFC.
  4. Read the code points, then copy the normalized string.

The summary is:

Form: NFC
Changed: yes
Before: U+0063 U+0061 U+0066 U+0065 U+0301 (5)
After: U+0063 U+0061 U+0066 U+00E9 (4)

The call is:

'cafe\u0301'.normalize('NFC')

Five code points become four. U+0065 and U+0301 become U+00E9. UTF-8 of U+0301 is CC 81. UTF-8 of U+00E9 is C3 A9.

Take the composed café and switch the form to NFD. You get the five code points back:

Form: NFD
Changed: yes
Before: U+0063 U+0061 U+0066 U+00E9 (4)
After: U+0063 U+0061 U+0066 U+0065 U+0301 (5)

The URL stores form=nfd, form=nfkc, or form=nfkd. NFC is the default, so that query is omitted. Files up to 1 MB open from Open file. The page reads strings up to 500,000 UTF-16 code units. The table shows the first 300 code points. Copy and Download use the full normalized string.

How this page normalizes a stringPaste a string, pick NFC, NFD, NFKC, or NFKD, and the page lists the code points before and after.Paste a stringPick a formString normalizeCode points beforeand after

The four forms

FormWhat this page does
NFCComposed, canonical
NFDDecomposed, canonical
NFKCComposed, compatibility
NFKDDecomposed, compatibility

Compatibility forms can replace a character with a different one. The ligature fi is U+FB01. Under NFKC it becomes the two letters f and i:

Form: NFKC
Changed: yes
Before: U+FB01 (1)
After: U+0066 U+0069 (2)

The note is: Compatibility normalization replaced characters. That change does not round-trip.

The call is:

'\ufb01'.normalize('NFKC')

NFC leaves that ligature as one code point. Use NFC when you want one stable spelling and you still want fi to stay fi.

A lone surrogate stays in place. It has no UTF-8 bytes, and the page says so.

The String normalize() method is the method reference. Unicode in JavaScript and Introduction to Unicode and UTF-8 cover the code points around it.

The string inspector lists units in a string. Encode and decode turns text into hex and Base64. Unicode search finds a character by name.

Try the Unicode Normalization

Convert a string to NFC, NFD, NFKC, or NFKD and list the code points before and after. The string stays in the browser and is not put in the URL.

Open the Unicode Normalization →

  • String Inspector: Why .length lies: UTF-16 units vs code points vs graphemes vs UTF-8 bytes, plus hidden-character detection and clean copy.
  • Encode / Decode: Encode or decode Base64, URL components, and HTML entities in your browser. Unicode-safe Base64 included.
  • Unicode Character Search: Find any character by name or paste one to decode it — code points, UTF-8 bytes, and HTML, JS, CSS escapes with copy buttons.

More tool tutorials →

Want me to talk about your product? You can sponsor this site.