DEV Community

San
San

Posted on

How to convert character to ASCII code using JavaScript ?

let text = "HELLO WORLD";
let code = text.charCodeAt(0);
Enter fullscreen mode Exit fullscreen mode
let text = "A";
let keyCode = text.charCodeAt(0);
console.log(keyCode)
Enter fullscreen mode Exit fullscreen mode

Output

Top comments (0)

Image of PulumiUP 2025

Let's talk about the current state of cloud and IaC, platform engineering, and security.

Dive into the stories and experiences of innovators and experts, from Startup Founders to Industry Leaders at PulumiUP 2025.

Register Now

👋 Kindness is contagious

Value this insightful article and join the thriving DEV Community. Developers of every skill level are encouraged to contribute and expand our collective knowledge.

A simple “thank you” can uplift someone’s spirits. Leave your appreciation in the comments!

On DEV, exchanging expertise lightens our path and reinforces our bonds. Enjoyed the read? A quick note of thanks to the author means a lot.

Okay