Last updated: August 28, 2026.
JavaScript strings use UTF-16 code units. Indexing can return half of a surrogate pair, so use codePointAt and iterate by Unicode characters.
Read one code point
Convert the numeric result to uppercase hexadecimal for U+ notation.
function unicodeLabel(character) {
const point = character.codePointAt(0);
if (point === undefined) throw new Error('A character is required.');
return 'U+' + point.toString(16).toUpperCase().padStart(4, '0');
}
console.log(unicodeLabel('A'));
console.log(unicodeLabel('\u{1F600}'));Inspect a complete string
A for-of loop advances by code point, keeping supplementary characters intact.
function listCodePoints(text) {
return Array.from(text, character => ({
character,
codePoint: 'U+' + character.codePointAt(0).toString(16).toUpperCase()
}));
}
console.table(listCodePoints('A\u0301'));Code points are not visible characters
Combining marks and joined emoji can contain several code points while appearing as one grapheme. Use Intl.Segmenter for cursor movement, truncation, or counting user-perceived characters.
Reference: MDN String.codePointAt reference.