CKTIS / JavaScript
String.prototype.normalize — Unicode normalization
normalize() returns text in a selected Unicode normalization form. It helps compare equivalent character representations and supports NFC, NFD, NFKC, and NFKD, defaulting to NFC.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
str.normalize(form = "NFC")String.prototype.normalize returns a normalized string without changing the input. Apparently identical text can contain different code point sequences: "\u00E9" and "e\u0301" represent é but are not equal with ===. Normalize both sides to the same form before comparing them.
"NFD" performs canonical decomposition; "NFC" also composes characters where Unicode specifies it. "NFKD" performs compatibility decomposition, while "NFKC" adds canonical composition. Compatibility forms can remove meaningful distinctions: the ligature "\uFB00" becomes "ff". Choose them deliberately, not as universal text cleanup.
Omitting form or passing undefined selects "NFC". Otherwise, the method attempts to convert form to a string. Passing a Symbol throws TypeError during this conversion. If conversion succeeds but the resulting string is not exactly one of "NFC", "NFD", "NFKC", or "NFKD", the method throws RangeError. Case matters. The receiver is converted to a string, but null and undefined receivers cause TypeError.
Normalization is neither case conversion nor general accent removal. It can change length, which counts UTF-16 code units rather than visible characters. This is an ECMAScript language method, not a DOM API; availability in a target browser must be checked independently of the Node version used by a project.
Examples
const composed = "\u00E9";
const decomposed = "e\u0301";
console.log(composed === decomposed);
console.log(composed.normalize() === decomposed.normalize());
console.log(composed.length, decomposed.length);
console.log(composed.normalize("NFD").length);
console.log("\uFB00".normalize("NFKC") === "ff");Result
false true 1 2 2 true
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.