String.fromCharCode(...nums) is a static method that builds a string from one or more UTF-16 code units (numbers 0–65535). Call it on String, not on a string value.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call String.fromCharCode. Start with this line.
JavaScript
String.fromCharCode(n1, n2, …)
Call
What it does
String.fromCharCode(n1, n2, …)
Primary signature.
String.fromCharCode(...)
Call with the arguments your case needs.
Built into JavaScript. Call String.fromCharCode(...) on the String constructor — no import required.
Library declarations
JavaScript
String.fromCharCode(n1, n2, …)
Parameters
Parameter
Description
Code unit numbers
Optional. Each arg → one UTF-16 unit; none → ""
Return Value
Return Value
Description
*
The value returned by String.fromCharCode().
JavaScript Examples
Example 1 — Build a String from Code Units
Pass one or more UTF-16 numbers to get characters back.
Read a unit.charCodeAt(0) returns the UTF-16 code for "A" → 65.
Rebuild the char.fromCharCode(65) returns "A" again.
Watch truncation.0x12014 keeps only the lowest 16 bits → same as 0x2014.
Pair them mentally. Numbers ↔ characters for BMP text use this duo.
Example 3 — fromCharCode vs fromCodePoint
Emoji need a surrogate pair with fromCharCode, or one call to fromCodePoint.
JavaScript
// Night with stars (U+1F303) — two UTF-16 units:
console.log(String.fromCharCode(0xd83c, 0xdf03));
// Same emoji with one Unicode code point:
console.log(String.fromCodePoint(0x1f303));
console.log(
String.fromCharCode(0xd83c, 0xdf03) ===
String.fromCodePoint(0x1f303)
); // true
UTF-16 split. Code points above U+FFFF need two units (a surrogate pair).
Manual pair.fromCharCode(0xd83c, 0xdf03) builds the emoji from those units.
Easier API.fromCodePoint(0x1f303) takes the full Unicode scalar value.
Rule of thumb. Prefer fromCodePoint for emoji and astral characters.
Compatibility
Browser & Runtime Support
String.fromCharCode() is a long-standing part of JavaScript. It works in all modern browsers and Node.js versions you are likely to target.
✓ Baseline · Widely available
String.fromCharCode()
Supported everywhere Unicode strings are — including legacy browsers. No polyfill needed for normal web or Node targets.
100%Universal support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
fromCharCode()Excellent
Bottom line: Safe to use in any environment that runs JavaScript. For astral Unicode (emoji), prefer String.fromCodePoint when available (ES2015+).
Frequently Asked Questions
String.fromCharCode(...nums) is a static method that builds a string from one or more UTF-16 code units (numbers from 0 to 65535). For example String.fromCharCode(65, 66, 67) returns "ABC".
No. It is a static method on the String constructor. Always write String.fromCharCode(...), not "text".fromCharCode(...).
Values above 0xFFFF are truncated to the lowest 16 bits. For example String.fromCharCode(0x12014) behaves like String.fromCharCode(0x2014) and returns an em dash.
Yes, but emoji above U+FFFF need a surrogate pair — two code units. Prefer String.fromCodePoint(0x1F303) when you know the full Unicode code point.
Use charCodeAt() for UTF-16 units or codePointAt() for full Unicode code points. Round-trip: String.fromCharCode("A".charCodeAt(0)) === "A".
An empty string "". Each argument you pass adds one UTF-16 code unit to the result.