In JavaScript, convert a number from 1 to 26 to a letter with String.fromCharCode(64 + n): String.fromCharCode(64 + 1) returns "A." Use 96 instead of 64 for lowercase. For spreadsheet columns, where 27 is "AA," loop with (n - 1) % 26.
Type numbers into the tool and pick A1Z26 or column letters. The tool writes the JavaScript for those numbers and runs it in the page, so the console panel shows real output. The code strip marks which character codes from 65 to 90 your numbers use.
How number to letter JavaScript calculator works?
To convert a number to a letter in JavaScript, the number to letter JavaScript calculator adds 64 to the number and reads the character with that code. The calculator splits your list of numbers, checks each one, converts 1–26 with String.fromCharCode(64 + n), or builds column letters (27 = AA) in column mode, and writes runnable JavaScript code for the same numbers. 8 5 12 12 15 becomes HELLO.
- Read the numbers
Spaces, commas, or new lines separate the numbers.
8 5 12 12 15 - Pick the mode
A1Z26 maps 1–26 to A–Z. Column mode maps any positive number to Excel column letters.
A1Z26 - Run String.fromCharCode(64 + n)
Each number n becomes the character with code 64 + n (A = 65 in ASCII and Unicode).
String.fromCharCode(64 + 8) = "H" - Write the code
The JavaScript snippet and its output appear side by side. Tick lowercase to use code 96 + n.
HELLO
Column mode runs a while loop: r = (n − 1) % 26, prepend String.fromCharCode(65 + r), then n = Math.floor((n − 1) / 26).
Number to letter JavaScript formula
The number to letter JavaScript formula is a code point offset. letter = character(64 + n) for capitals and character(96 + n) for lowercase, for n from 1 to 26. Column letters use bijective base 26: take (n − 1) mod 26, then divide (n − 1) by 26, and repeat.
Formula
Where
- n
- number from 1 to 26 (A1Z26) or any positive whole number (columns)
- 64
- ASCII code of @, the character before A (65)
- 96
- ASCII code of `, the character before a (97)
- r
- remainder 0–25, read as A–Z
Worked example
Number to letter JavaScript conversion chart
The number to letter JavaScript conversion chart lists all 26 A1Z26 numbers with the ASCII codes and the JavaScript expression. 1 = A (code 65), 13 = M (code 77), and 26 = Z (code 90).
| n | Letter | Code (capital) | Code (lowercase) | JavaScript expression |
|---|---|---|---|---|
| 1 | A | 65 | 97 | fromCharCode(65) → "A" |
| 2 | B | 66 | 98 | fromCharCode(66) → "B" |
| 3 | C | 67 | 99 | fromCharCode(67) → "C" |
| 4 | D | 68 | 100 | fromCharCode(68) → "D" |
| 5 | E | 69 | 101 | fromCharCode(69) → "E" |
| 6 | F | 70 | 102 | fromCharCode(70) → "F" |
| 7 | G | 71 | 103 | fromCharCode(71) → "G" |
| 8 | H | 72 | 104 | fromCharCode(72) → "H" |
| 9 | I | 73 | 105 | fromCharCode(73) → "I" |
| 10 | J | 74 | 106 | fromCharCode(74) → "J" |
| 11 | K | 75 | 107 | fromCharCode(75) → "K" |
| 12 | L | 76 | 108 | fromCharCode(76) → "L" |
| 13 | M | 77 | 109 | fromCharCode(77) → "M" |
| 14 | N | 78 | 110 | fromCharCode(78) → "N" |
| 15 | O | 79 | 111 | fromCharCode(79) → "O" |
| 16 | P | 80 | 112 | fromCharCode(80) → "P" |
| 17 | Q | 81 | 113 | fromCharCode(81) → "Q" |
| 18 | R | 82 | 114 | fromCharCode(82) → "R" |
| 19 | S | 83 | 115 | fromCharCode(83) → "S" |
| 20 | T | 84 | 116 | fromCharCode(84) → "T" |
| 21 | U | 85 | 117 | fromCharCode(85) → "U" |
| 22 | V | 86 | 118 | fromCharCode(86) → "V" |
| 23 | W | 87 | 119 | fromCharCode(87) → "W" |
| 24 | X | 88 | 120 | fromCharCode(88) → "X" |
| 25 | Y | 89 | 121 | fromCharCode(89) → "Y" |
| 26 | Z | 90 | 122 | fromCharCode(90) → "Z" |
Column numbers past 26
| n | Column letters |
|---|---|
| 27 | AA |
| 28 | AB |
| 52 | AZ |
| 53 | BA |
| 78 | BZ |
| 702 | ZZ |
| 703 | AAA |
| 1,000 | ALL |
| 16,384 | XFD |
JavaScript number to letter examples
// single number
String.fromCharCode(64 + 5); // "E"
// lookup string
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[5 - 1]; // "E"
// whole message
[8, 5, 12, 12, 15].map(n => String.fromCharCode(64 + n)).join(""); // "HELLO"
// letter to number
"E".charCodeAt(0) - 64; // 5
String.fromCharCode takes UTF-16 code units; 65 is "A" and 97 is "a." It accepts several codes at once: String.fromCharCode(...[72, 73]) returns "HI."
Column letters in JavaScript
function toColumn(n) {
let s = "";
while (n > 0) {
const r = (n - 1) % 26;
s = String.fromCharCode(65 + r) + s;
n = Math.floor((n - 1) / 26);
}
return s;
}
toColumn(28); // "AB"
toColumn(16384); // "XFD"
const fromColumn = s => [...s.toUpperCase()].reduce((a, c) => a * 26 + c.charCodeAt(0) - 64, 0);
fromColumn("AB"); // 28
Use Math.floor, not bitwise | 0, if the numbers can pass 2,147,483,647.
Frequently asked questions
How do I convert a number to a letter in JavaScript?
Use String.fromCharCode(64 + n). For n = 3 it returns "C."
How do I convert a letter to a number in JavaScript?
Use letter.toUpperCase().charCodeAt(0) - 64. "C" returns 3.
What is the difference between fromCharCode and fromCodePoint?
fromCodePoint handles characters above 65,535, such as emoji. For A to Z both return the same letters.
How do I get lowercase letters?
Use String.fromCharCode(96 + n) or add .toLowerCase().
What is the JavaScript formula for number to letter?
The JavaScript formula is String.fromCharCode(64 + n), so String.fromCharCode(67) returns "C".
What does String.fromCharCode(65) return?
String.fromCharCode(65) returns "A". 90 returns "Z" and 97 returns "a".
How do I map an array of numbers to letters in JavaScript?
Use nums.map(n => String.fromCharCode(64 + n)).join(""). [3, 1, 20] returns "CAT".
More number and letter tools