JavaScript String normalize() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

String.prototype.normalize(form?) returns a new string in a Unicode Normalization Form so equivalent characters compare the same. Default form is NFC. It never mutates the original string.

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call string.normalize. Start with this line.

JavaScript
str.normalize([form])
CallWhat it does
str.normalize([form])Primary signature.
string.normalize(...)Call with the arguments your case needs.

Built into JavaScript. Call normalize(...) on a string (or String instance) — no import required.

Library declarations
JavaScript
str.normalize([form])

Parameters

ParameterDescription
formOptional. "NFC" (default), "NFD", "NFKC", or "NFKD"

Return Value

Return ValueDescription
*The value returned by string.normalize().

JavaScript Examples

Example 1 — Fix Equality with NFC

Two spellings of Amélie look the same but fail === until normalized.

JavaScript
const name1 = "\u0041\u006d\u00e9\u006c\u0069\u0065"; // Amélie (composed)
const name2 = "\u0041\u006d\u0065\u0301\u006c\u0069\u0065"; // Amélie (e + accent)

console.log(name1 === name2);                         // false
console.log(name1.normalize("NFC") === name2.normalize("NFC")); // true
Try It Yourself

How It Works

  1. Build two lookalikes. name1 uses a precomposed é; name2 uses e plus a combining accent.
  2. Raw compare fails. Different code points → === is false.
  3. Normalize both to NFC. Each becomes the same composed sequence.
  4. Compare again. Now === is true — safe for keys and checks.

Example 2 — NFC vs NFD for "ñ"

Either form works for equality — stay consistent on both sides.

JavaScript
const a = "\u00F1";       // ñ (one code point)
const b = "\u006E\u0303"; // n + combining tilde

console.log(a === b);                               // false
console.log(a.normalize("NFD") === b.normalize("NFD")); // true
console.log(a.normalize("NFC") === b.normalize("NFC")); // true
console.log(a.normalize("NFD").length);             // 2
console.log(a.normalize("NFC").length);             // 1
Try It Yourself

How It Works

  1. Two encodings of ñ. One code point vs base n plus tilde.
  2. NFD decomposes. Both become length 2 and compare equal.
  3. NFC recomposes. Both become length 1 and compare equal.
  4. Pick one form. Mixing NFC on one side and NFD on the other can still fail.

Example 3 — Compatibility: "ff" → "ff"

NFKD folds a ligature into two plain letters — useful for search.

JavaScript
const ligature = "\uFB00"; // ff
const plain = "ff";

console.log(ligature === plain);                              // false
console.log(ligature.normalize("NFKD") === plain.normalize("NFKD")); // true
console.log(ligature.normalize("NFKD"));                      // "ff"
Try It Yourself

How It Works

  1. Start with a ligature. ff is one character; "ff" is two.
  2. Canonical forms keep them apart. NFC/NFD do not fold this ligature to ff.
  3. NFKD applies compatibility. The ligature becomes plain "ff".
  4. Trade-off. Great for search indexes; avoid if you must preserve exact appearance.

Browser & Runtime Support

String.prototype.normalize() is part of ES2015 and is Baseline Widely available across modern browsers since 2016.

✓ Baseline · ES2015

String.prototype.normalize()

Supported in Chrome 34+, Firefox 31+, Safari 10+, Edge 12+, and Node.js 0.12+. Not available in Internet Explorer.

98% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
String.normalize() Excellent

Bottom line: Safe for production equality and storage keys. Prefer NFC unless you need decomposition or compatibility folding. Feature-detect with if ("normalize" in String.prototype) for very old targets.

Frequently Asked Questions

normalize(form?) returns a new string in a Unicode Normalization Form: NFC, NFD, NFKC, or NFKD. The default is NFC. It does not change the original string.
Unicode can store the same character as one code point (composed) or as a base letter plus combining marks (decomposed). They look the same but differ until you normalize both sides.
Both are canonical. NFD decomposes into base + marks. NFC decomposes then recomposes into precomposed characters where possible. Use either consistently before comparing.
For compatibility folding — for example treating the ligature ff like "ff". Useful for search; be careful for display because appearance can change.
normalize() throws RangeError if form is not "NFC", "NFD", "NFKC", or "NFKD".
No. Strings are immutable. normalize() returns a new normalized string.

Next: padEnd()

Learn how to pad a string to a target length by adding characters at the end.

padEnd() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful