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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

String.fromCodePoint(cp1, cp2, /* …, */ cpN)

Parameters

ParameterDescription
codePoints Numbers between 0 and 0x10FFFF.

Return value

A string.

Examples

Emoji from code pointsTry it yourself
const s = String.fromCodePoint(0x1F42B, 0x2728);
console.log(s === "\u{1F42B}\u{2728}", s.length, [...s].length);

Output

true 3 2
Invalid code points throwTry it yourself
try {
  String.fromCodePoint(-1);
} catch (e) {
  console.log(e.name);
}

Output

RangeError

Version history

VersionChange
JavaScript ES2015Added

In other languages

Was this page helpful?