In Excel: use =BASE(number, radix) to convert a decimal number into another base, and =DECIMAL(text, radix) to convert it back.
On this page8
Syntax
Arguments
| Argument | required / optional | Description |
|---|---|---|
number | required | The decimal number to convert. |
radix | required | Target base, 2 to 36 — 2 binary, 16 hexadecimal. |
min_length | optional | Pad the result with leading zeros to this length. |
Related functions
Excel columns run A–XFD (1–16384).
A = 1 · XFD = 16384
Need it as an auditable file?
Ships inside the linked template — formula-driven, unlocked, audit-ready.
What this does
BASE converts a decimal number into any base from 2 to 36, and DECIMAL reverses it. They generalise the older DEC2BIN and HEX2DEC family, which are limited to specific bases and to small ranges — BASE handles far larger numbers and any radix, which makes it the better default. Their real-world uses are narrow but genuine: reading hex colour codes, decoding permission bitmasks, and generating short alphanumeric identifiers by encoding a counter in base 36. The optional min_length pads with leading zeros, which matters for fixed-width identifiers. The same idea underpins a lot of everyday Excel work, so the few minutes spent getting it right here pay back across every sheet you build afterwards. Treat it as a pattern, not a one-off, and it stops being something you look up and starts being something you reach for. For “excel base function”, the reliable version is a short checking loop, not just the first command that appears to work. Run it on a deliberately small range first, watch how the affected formula change, and only then apply the same setup to the full sheet. When a formula is involved, keep the inputs labelled beside it, reference cells instead of typing values, and apply number formatting only after the result checks out. That is what makes a calculation you can defend to a CFO or an auditor useful in real work: repeatable, auditable, and not dependent on memory or luck.
A worked example
A decimal 255 as hexadecimal: =BASE(255, 16) returns "FF". Back again: =DECIMAL("FF", 16) returns 255. An 8-bit binary representation with padding: =BASE(5, 2, 8) returns "00000101". A short ID from a row counter: =BASE(ROW()*7919, 36). BASE and DECIMAL cover every radix conversion in two functions, where the legacy family needed one per base pair and capped out early. One habit worth forming early: name the cells that hold your inputs, so the formula reads in plain language instead of a string of cell addresses. A reviewer — or you in three months — can then follow the logic without decoding what B7 and D2 were supposed to mean, which is most of what makes a sheet maintainable.
In Google Sheets
If you are in Google Sheets rather than Excel, the good news is that the formula shown here is identical and the workflow barely changes — menus sit across the top instead of in a ribbon, and a few function names differ slightly, but anything you build here moves across with little or no rework. Keep this page bookmarked for the next time the same question comes up. Better still, rebuild the example once in your own sheet — doing it yourself, with the tool above to check against, is what turns a copied formula into a technique you own. Treat “excel base function” as a small building block rather than a chore. Once the inputs sit in their own cells and the formula reads from them, the same setup answers a dozen related questions with a tweak, and Excel keeps every dependent figure current as the data changes. The tool above is there so you can rehearse and verify before committing anything to a real workbook; the steps and worked example are there so the logic sticks. Get it right once and it stops costing you time — it starts saving it, every time the question comes back around.
Common mistakes
- Expecting BASE to return a number; it returns text, so the result cannot be summed.
- A radix outside 2 to 36, which returns
#NUM!. - Reaching for DEC2BIN and friends, which are limited to small ranges where BASE is not.
Frequently asked questions
How do I convert decimal to hex?
=BASE(A2, 16). To go back, =DECIMAL(A2, 16).
What is the difference from DEC2HEX?
BASE handles any base from 2 to 36 and much larger numbers; DEC2HEX is limited to hex and a small range.
How do I pad binary to 8 digits?
Pass the length as the third argument: =BASE(5, 2, 8) returns "00000101".