In Python, convert a number from 1 to 26 to its letter with chr(n + 64) for capitals or chr(n + 96) for lowercase: chr(1 + 64) returns 'A'. A lookup works too: string.ascii_uppercase[n - 1]. For spreadsheet column letters such as 28 → 'AB', loop with divmod(n - 1, 26).
Type numbers into the tool and pick A1Z26 or column letters. It prints the letters, writes a Python script for those exact numbers, and shows a REPL session with every expression and its output.
How number to letter Python calculator works?
To convert a number to a letter in Python, the number to letter Python 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 chr(64 + n), or builds column letters (27 = AA) in column mode, and writes runnable Python 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 chr(64 + n)
Each number n becomes the character with code 64 + n (A = 65 in ASCII and Unicode).
chr(64 + 8) = 'H' - Write the code
The Python snippet and its output appear side by side. Tick lowercase to use code 96 + n.
HELLO
Column mode runs the divmod loop: n, r = divmod(n − 1, 26), adding chr(65 + r) to the front until n is 0. string.ascii_uppercase[n − 1] gives the same letter as chr(64 + n).
Number to letter Python formula
The number to letter Python 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 Python conversion chart
The number to letter Python conversion chart lists all 26 A1Z26 numbers with the ASCII codes and the Python expression. 1 = A (code 65), 13 = M (code 77), and 26 = Z (code 90).
| n | Letter | Code (capital) | Code (lowercase) | Python expression |
|---|---|---|---|---|
| 1 | A | 65 | 97 | chr(65) → 'A' |
| 2 | B | 66 | 98 | chr(66) → 'B' |
| 3 | C | 67 | 99 | chr(67) → 'C' |
| 4 | D | 68 | 100 | chr(68) → 'D' |
| 5 | E | 69 | 101 | chr(69) → 'E' |
| 6 | F | 70 | 102 | chr(70) → 'F' |
| 7 | G | 71 | 103 | chr(71) → 'G' |
| 8 | H | 72 | 104 | chr(72) → 'H' |
| 9 | I | 73 | 105 | chr(73) → 'I' |
| 10 | J | 74 | 106 | chr(74) → 'J' |
| 11 | K | 75 | 107 | chr(75) → 'K' |
| 12 | L | 76 | 108 | chr(76) → 'L' |
| 13 | M | 77 | 109 | chr(77) → 'M' |
| 14 | N | 78 | 110 | chr(78) → 'N' |
| 15 | O | 79 | 111 | chr(79) → 'O' |
| 16 | P | 80 | 112 | chr(80) → 'P' |
| 17 | Q | 81 | 113 | chr(81) → 'Q' |
| 18 | R | 82 | 114 | chr(82) → 'R' |
| 19 | S | 83 | 115 | chr(83) → 'S' |
| 20 | T | 84 | 116 | chr(84) → 'T' |
| 21 | U | 85 | 117 | chr(85) → 'U' |
| 22 | V | 86 | 118 | chr(86) → 'V' |
| 23 | W | 87 | 119 | chr(87) → 'W' |
| 24 | X | 88 | 120 | chr(88) → 'X' |
| 25 | Y | 89 | 121 | chr(89) → 'Y' |
| 26 | Z | 90 | 122 | chr(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 |
3 ways to convert numbers to letters in Python
# 1. chr() with an offset: 65 is the code of 'A'
chr(5 + 64) # 'E'
# 2. lookup in the alphabet string
import string
string.ascii_uppercase[5 - 1] # 'E'
# 3. whole message
nums = [8, 5, 12, 12, 15]
''.join(chr(n + 64) for n in nums) # 'HELLO'
chr() returns the character for a Unicode code point; capital A is 65 and lowercase a is 97. Adding 64 makes 1 map to A, which is the A1Z26 convention. Use 65 if your numbers start at 0.
Letter to number in Python
ord('E') - 64 # 5
[ord(c) - 64 for c in 'HELLO'.upper() if c.isalpha()] # [8, 5, 12, 12, 15]
def col_num(s): # 'AB' -> 28
n = 0
for c in s.upper():
n = n * 26 + ord(c) - 64
return n
Column letters with divmod
Spreadsheet columns use bijective base 26, so subtract 1 before each divmod. Without it, 26 becomes 'A@' instead of 'Z'. openpyxl ships the same logic as openpyxl.utils.get_column_letter(28), which returns 'AB', and column_index_from_string('AB') returns 28.
Frequently asked questions
How do I convert a number to a letter in Python?
Use chr(n + 64) for capitals or chr(n + 96) for lowercase. chr(3 + 64) returns "C."
How do I convert 0 to A in Python?
For 0-based numbers, use chr(n + 65) or string.ascii_uppercase[n].
How do I convert a letter to a number in Python?
Use ord(letter.upper()) - 64. ord("C") - 64 returns 3.
How do I get an Excel column letter in Python?
Use the divmod loop on this page or openpyxl.utils.get_column_letter(n).
What is the Python formula for number to letter?
The Python formula is chr(64 + n), so chr(64 + 3) returns 'C'. Use chr(96 + n) for lowercase.
What does chr(65) return in Python?
chr(65) returns 'A'. chr(90) returns 'Z' and chr(97) returns 'a'.
How do I convert a list of numbers to a word in Python?
Use ''.join(chr(64 + n) for n in nums). [3, 1, 20] returns 'CAT'.
More number and letter tools