JavaScript String.fromCharCode() Method
The String.fromCharCode() static method creates a string from one or more UTF-16 character codes.
Description
The String.fromCharCode() static method returns a string created from a sequence of UTF-16 code units. For characters above U+FFFF, such as emoji, use String.fromCodePoint(), which takes full code points.
Numbers are truncated to 16 bits, so values above 65535 wrap around rather than producing the character you might expect. That's why String.fromCodePoint(), which accepts the full Unicode range and throws a RangeError for invalid code points, is the safer choice for anything beyond basic text.
It's commonly used with spread syntax to turn an array of codes back into text, the reverse of mapping a string with charCodeAt(). For converting bytes of encoded text, such as UTF-8 data from a file, use TextDecoder instead.
Syntax
String.fromCharCode(num1, num2, ...)Parameters
- num1, num2, ...UTF-16 code units, numbers from 0 to 65535.
Return Value
A string made from the given code units.
Example
Browser Support
The following information will show you the current browser support for the String.fromCharCode() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





