String.fromCodePoint()
String.fromCodePoint(...codePoints) Returns:
String · Updated March 13, 2026 · String Methods javascript string unicode code-point
String.fromCodePoint() is a static method that returns a string built from one or more Unicode code points. Unlike the older String.fromCharCode(), it correctly handles code points above U+FFFF (supplementary characters such as emoji and rare scripts).
Syntax
String.fromCodePoint(num1)
String.fromCodePoint(num1, num2)
String.fromCodePoint(num1, num2, /* …, */ numN)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| …codePoints | Number | required | One or more Unicode code points (integers between 0 and 0x10FFFF). |
Return Value
A string formed by the characters corresponding to the specified code points. Throws a RangeError if any code point is not a valid Unicode value (e.g. negative or > 0x10FFFF).
Examples
Basic ASCII characters
String.fromCodePoint(65, 66, 67);
// 'ABC'
String.fromCodePoint(9731, 9733, 9842);
// '☃★♲'
Emoji (above U+FFFF)
String.fromCodePoint(0x1F600);
// '😀'
String.fromCodePoint(0x1F4A9);
// '💩'
String.fromCodePoint(128512);
// '😀' (128512 === 0x1F600)
Multiple code points
String.fromCodePoint(72, 101, 108, 108, 111);
// 'Hello'
Invalid code point throws RangeError
String.fromCodePoint(-1);
// RangeError: Invalid code point -1
String.fromCodePoint(0x110000);
// RangeError: Invalid code point 1114112
Common Patterns
Encoding emoji by name
const EMOJI = {
smile: 0x1F600,
heart: 0x2764,
thumbUp: 0x1F44D,
};
function emoji(name) {
return String.fromCodePoint(EMOJI[name]);
}
console.log(emoji('smile')); // 😀
console.log(emoji('heart')); // ❤
console.log(emoji('thumbUp')); // 👍
Converting code point array to string
const codePoints = [72, 101, 108, 108, 111, 32, 127758];
const result = String.fromCodePoint(...codePoints);
console.log(result);
// 'Hello 🌎'
Generating a Unicode range
// Generate all uppercase Latin letters
const letters = Array.from({ length: 26 }, (_, i) =>
String.fromCodePoint(65 + i)
);
console.log(letters.join(',')); // A,B,C,...,Z
See Also
- String.prototype.codePointAt() — returns the code point of a character
- String.fromCharCode() — older method limited to U+FFFF
- String.prototype.at() — access characters by index