JavaScript (ES2026) reference · String Methods
JavaScript String.fromCodePoint() Method
Create a string from Unicode code points, including emoji outside the BMP that fromCharCode() can't express in one number.
JavaScript (ES2026) Since ES2015
Syntax
String.fromCodePoint(cp1, cp2, /* …, */ cpN)
Parameters
| Parameter | Description |
|---|---|
codePoints |
Numbers between 0 and 0x10FFFF. |
Return value
A string.
Examples
const s = String.fromCodePoint(0x1F42B, 0x2728);
console.log(s === "\u{1F42B}\u{2728}", s.length, [...s].length);
Output
true 3 2
try {
String.fromCodePoint(-1);
} catch (e) {
console.log(e.name);
}
Output
RangeError
Version history
| Version | Change |
|---|---|
| JavaScript ES2015 | Added |
In other languages
Related
String.fromCharCode()· Create a string from UTF-16 code units, for example String.fromCharCode(72, 105) gives "Hi".string.codePointAt()· Return the full Unicode code point at an index, correctly handling emoji and other characters outside the BMP.- JavaScript Strings · tutorial
- JavaScript String Methods · tutorial