String.fromCharCode
Returns a string created from the specified sequence of UTF-16 code units
Syntax
String.fromCharCode(...nums)Parameters
| Parameter | Type | Description |
|---|---|---|
| nums | number[] | Sequence of numbers that are UTF-16 code units |
Return Value
A string of the specified characters
Examples
console.log(String.fromCharCode(72, 101, 108, 108, 111)); // 'Hello'console.log(String.fromCharCode(65)); // 'A'
console.log(String.fromCharCode(9731)); // '☃'const chars = [74, 83].map(c => String.fromCharCode(c));
console.log(chars.join('')); // 'JS'Understanding String.fromCharCode
The String.fromCharCode method in JavaScript returns a string created from the specified sequence of UTF-16 code units. It belongs to the String object and is one of the most widely used methods for working with string values in modern JavaScript and TypeScript applications.
The method signature is String.fromCharCode(...nums). It accepts 1 parameter: nums. When called, it returns a string of the specified characters. Understanding when and how to use fromCharCode() helps you write more expressive, readable code.
Common use cases for String.fromCharCode include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like string-fromcodepoint, string-charcodeat, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for String.fromCharCode is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
More String Methods
Other methods in the String object
Related Tools
More String Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.