Calculate the UTF-16 encoded byte size and compare it with UTF-8.
UTF-16 uses two bytes for most characters and four for supplementary ones through surrogate pairs. It is more compact than UTF-8 for Asian scripts but wasteful for ASCII-heavy text. Because JavaScript strings are UTF-16, the length property counts code units rather than characters, which is why an emoji reports a length of two.
UTF-16 Byte Size
UTF-16 bytes = code units × 2, where supplementary characters take two code units
UTF-16 bytes = code units × 2, where supplementary characters take two code units UTF-16 uses two bytes for most characters and four for supplementary ones through surrogate pairs. It is more compact than UTF-8 for Asian scripts but wasteful for ASCII-heavy text.
Because JavaScript strings are UTF-16, the length property counts code units rather than characters, which is why an emoji reports a length of two.
This calculator takes 3 inputs: Basic multilingual plane characters, Supplementary plane characters such as emoji, Share of the text that is ASCII. The pre-filled defaults are a realistic starting point — replace them with figures from your own environment for a result you can act on.