Favorites

JavaScript String.prototype.codePointAt() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
String.prototype.codePointAt()
JavaScript String Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The codePointAt() method returns the full Unicode code point of the character at a given position, including emoji and other characters beyond the basic range.

Description

The codePointAt() method returns the Unicode code point starting at the given index. Unlike charCodeAt(), it correctly combines surrogate pairs, so it returns the real value for emoji and other characters above U+FFFF. Its counterpart for creating characters is String.fromCodePoint().

The index is still counted in UTF-16 code units, not characters, so when walking through a string by index you need to skip the second half of each surrogate pair. Looping with for...of avoids that, because it yields one whole code point at a time, which you can then pass to codePointAt(0).

Code points are often written in hexadecimal, such as U+1F600; toString(16) converts the number into that form. In regular expressions, the u flag and \u{...} escapes work with whole code points in the same way.

Syntax

string.codePointAt(index)

Parameters

  • indexThe position, in UTF-16 code units.

Return Value

The Unicode code point at that position, or undefined if the index is out of range.

Example

console.log('😀'.codePointAt(0));
console.log('😀'.codePointAt(0).toString(16));
console.log(String.fromCodePoint(128512));

Browser Support

The following information will show you the current browser support for the String.prototype.codePointAt() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee