What is a code point?

A code point is simply the number Unicode gives a character. The fire emoji πŸ”₯ is code point U+1F525. Understanding code points clears up a lot of confusion about text and emoji.

The U+ notation

Code points are written as U+ followed by hexadecimal digits: U+0041 (A), U+00E9 (Γ©), U+1F600 (πŸ˜€). The range runs from U+0000 to U+10FFFF.

Code point β‰  byte

A code point is an abstract number. How many bytes it takes to store depends on the encoding: in UTF-8, β€œA” is 1 byte but πŸ˜€ is 4 bytes. Don't confuse the character's identity (its code point) with its storage (its bytes).

Code point β‰  what users see

What a person perceives as one character (a β€œgrapheme”) can be several code points β€” an emoji with a skin tone, or a flag, is multiple code points combined. So β€œlength” in code points isn't the same as visible characters.

'πŸ”₯'.codePointAt(0).toString(16)  // '1f525'
'πŸ‘¨\u200dπŸ’»'.length              // 5 (multiple code units!)

Frequently asked questions

How do I find a character's code point?

In JavaScript, 'πŸ”₯'.codePointAt(0) returns the number; format it as hex and prefix U+.

Is a code point one byte?

No β€” a code point is a number that may take 1–4 bytes to encode, depending on the encoding.