Convert the input string to the specified Unicode normalization form.
NORMALIZE(str [, form])
## Overview Converts the input string to the specified Unicode normalization form. Normalisation ensures that visually identical strings compare equal at the byte level. NFC (canonical composition) is the default and is appropriate for almost all comparison and storage tasks. NFD (canonical decomposition) is useful as an intermediate step before stripping combining marks for accent-folding. NFKC and NFKD apply compatibility decomposition, which can fold ligatures and presentation forms. Always normalise text before comparing strings that come from different sources. A column populated by a form backend that emits NFC and by a mobile client that emits NFD will silently fail to join until both sides are normalised to the same form. ## Behavior - Returns NULL when the input is NULL. - Returns the input unchanged when it is already in the requested form (equivalent to what IS_NORMALIZED reports). - Supported forms: NFC, NFD, NFKC, NFKD. - NFC produces the shortest precomposed encoding. - NFD produces the fully decomposed encoding with combining marks following their base characters. - NFKC and NFKD additionally apply compatibility decomposition, which can change the semantic content of a string (ligatures decompose, superscripts become plain digits, etc.). - ASCII input is returned unchanged in any form. - Operates on Unicode code points using the engine's current Unicode version. ## Compatibility - Matches the common SQL NORMALIZE semantics and the Unicode Consortium's standard forms.
| Name | Type | Description |
|---|---|---|
str | Specifies the input string to normalize. | |
form | Specifies the target Unicode normalization form. Valid values are 'NFC', 'NFD', 'NFKC', and 'NFKD'. Defaults to 'NFC'. |
-- Default NFC
SELECT NORMALIZE('café');
-- Explicit NFC (canonical composition)
SELECT NORMALIZE('café', 'NFC');
-- NFD decomposes precomposed characters
SELECT NORMALIZE('café', 'NFD'); -- 'e' + combining acute for the final letter
-- NFKC applies compatibility folding
SELECT NORMALIZE('fi', 'NFKC'); -- 'fi'
-- NULL propagates
SELECT NORMALIZE(CAST(NULL AS VARCHAR)); -- NULL
-- Normalise a name column to NFC before storing
SELECT NORMALIZE(TRIM(full_name), 'NFC') AS full_name_clean
FROM retail.customers.profiles;