Excel Column ↔ Number Converter

Convert Excel column letters (A, AB, ZZZ) to column numbers

Convert Excel-style column letters such as A, AB, or ZZZ to their 1-based integer index and back. Uses true bijective base-26 arithmetic, the same scheme Excel and Google Sheets use. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How does Excel number its columns?

Excel uses bijective base-26: A=1, B=2, up to Z=26, then AA=27, AB=28, and so on. There is no zero digit, which is why it is called bijective rather than ordinary base-26.

Why Excel columns are not ordinary base-26

Spreadsheet column labels look like base-26, but they use a quirk called bijective numeration. In ordinary base-26 you would need a zero symbol, but column labels have no zero. The symbols run A through Z (values 1 through 26), so after Z comes AA — not BA. That single difference breaks naive base-26 conversion for multi-letter columns.

This matters in practice any time you programmatically generate column references — in Python pandas, in database export scripts, in formula engines, or in data pipelines that address columns by index.

The algorithms

Letters to number — scan left to right, accumulating position:

total = 0
for each letter (left to right):
    total = total × 26 + letterValue    (A=1 … Z=26)

So AB is 1 × 26 + 2 = 28. ZZ is 26 × 26 + 26 = 702. AAA is 1 × 676 + 1 × 26 + 1 = 703.

Number to letters — peel off letters from the right, subtracting one each step to account for the missing zero:

while n > 0:
    n = n − 1
    letter = 'A' + (n mod 26)
    prepend letter
    n = floor(n / 26)

The subtract-one before each division is the key. Without it, column 26 would map to Z0 (impossible), not Z. With it, 26 maps correctly to Z, 27 to AA, and so on.

Reference: key column values

LabelIndexNotes
A1First column
Z26Last single-letter column
AA27First two-letter column
AZ52
BA53
ZZ702Last two-letter column
AAA703First three-letter column
XFD16384Last column in modern Excel (1,048,576 rows)
XFE16385Beyond Excel’s range; valid in the math, not in a sheet

Common use cases

  • Generating CSV headers from a column count: convert integers 1 through N to labels A, B, …, Z, AA, AB, … to match what Excel would call those columns.
  • Reading VLOOKUP or INDEX formulas from code: when you know the column number from your data model and need the letter label for a formula string.
  • Validating data exports: check that an exported column reference matches the expected index before processing.
  • Formula engines and low-code tools: many formula parsing libraries expose columns by index internally and display them by letter in the UI.

The converter handles arbitrarily long labels and any positive integer index, so it is safe for large datasets that exceed the XFD limit if you are working outside Excel itself.