JavaScript fromCharCode()

ArieGonzAguer's avatar
Published Jun 12, 2025
Contribute to Docs

In JavaScript, the fromCharCode() method creates a string by converting one or more UTF-16 code units (numeric values) into their corresponding characters. This method is often applied in scenarios involving character encoding, dynamic character generation, or simple encryption tasks. It is particularly useful for converting ASCII or Unicode values into readable text.

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
    • Beginner Friendly.
      15 hours

Syntax

String.fromCharCode(num1, num2, ..., numN)

Parameters:

  • num1, num2, ..., numN (Number): One or more integer values representing UTF-16 code units. Each number should be between 0 and 65535.

Return value:

Returns a string composed of characters corresponding to the provided UTF-16 code units.

Example

The following code converts a sequence of UTF-16 code units into the string “Liany❤️” and logs it to the console:

const number = String.fromCharCode(76, 105, 97, 110, 121, 10084, 65039);
console.log(number);

The output of this code is:

Liany❤️

Codebyte Example

Run the following code to understand the working of the fromCharCode() method:

Code
Output

All contributors

Contribute to Docs

Learn JavaScript on Codecademy

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
    • Beginner Friendly.
      15 hours