Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

String.fromCharCode

Creates a string from character codes.

Available since: ES1

Syntax

String.fromCharCode(code1, code2, /* … */)

Parameters

ParameterTypeDescription
code1, …numberUTF-16 character codes.

Return value

stringA string made of those characters.

Examples

Letters from their codes:

console.log(String.fromCharCode(72, 105));

Output:

Hi

An alphabet from a range of codes:

const letters = Array.from({ length: 5 }, (_, i) => String.fromCharCode(65 + i));
 
console.log(letters.join(''));

Output:

ABCDE

Notes

It is a static method: you call it on String itself, not on a string.

See also

In the tutorial

  • String methods — Useful string methods in JavaScript: finding a position, reading characters, padStart, repeat, split and join, method chains.

Thanks for reading!

Donate to the site — we work hard for you.