Math & trig function

BASE function

Converts a number into text in another base (radix 2–36), e.g. binary, hexadecimal or base 36.

Available in Excel 2013 and later, Microsoft 365, Excel for the web, Excel for Mac 2016 and later

Excel 2013 and laterWorks in Google Sheets

Syntax

BASE(number, radix, [min_length])
ArgumentWhat it means
numberRequiredA whole number from 0 to 2^53 − 1.
radixRequiredThe target base, 2 to 36 (2 binary, 8 octal, 16 hex, 36 uses 0–9 and A–Z).
min_lengthOptionalMinimum length of the result; it is padded with leading zeros.

Returns: Text representing the number in the chosen base.

How BASE works

BASE writes a number in any base from 2 to 36. =BASE(255, 16) returns FF and =BASE(10, 2) returns 1010. It is handy for colour codes, binary flags, IT addresses and for turning long numeric IDs into short codes in base 36, which uses all digits and letters.

Unlike the older DEC2BIN and DEC2HEX, BASE handles any radix and much larger numbers (up to 2^53 − 1), but not negative values. The optional min_length pads with zeros, so BASE(10, 2, 8) gives the 8-bit form 00001010. Convert back with DECIMAL.

Examples

1Hex colour code from RGB values

E2fx="#"&BASE(B2,16,2)&BASE(C2,16,2)&BASE(D2,16,2)
ABCDE
1ColourRedGreenBlue
2Brand teal0128128#008080

Result: #008080

Each channel becomes two hex digits (0 → 00, 128 → 80), joined into a web colour code.

2Eight-bit binary flags

A1fx=BASE(10, 2, 8)
A
100001010

Result: 00001010

10 in binary is 1010; min_length 8 pads it to a full byte.

3Short code from a long order number

B2fx=BASE(A2, 36)
AB
1Order no.
212345678921I3V9

Result: 21I3V9

Base 36 squeezes the 9-digit number into 6 characters, useful for short reference codes.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 15 KB

Common errors and how to fix them

ErrorWhy it happensFix
#NUM!Number negative or ≥ 2^53, or radix outside 2–36.Check the inputs.
#VALUE!Non-numeric argument.Check the inputs.

Tips

  • The result is text; use DECIMAL to calculate with it again.

Google Sheets

BASE also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

BASE in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
DanishBASIS
DutchBASIS
FinnishPERUS
GermanBASIS
HungarianALAP
Norwegian (Bokmål)GRUNNTALL
PolishPODSTAWA
RussianОСНОВАНИЕ
SwedishBAS
TurkishTABAN