The BASE function converts a number from base 10 into a text representation in another base, such as binary or hexadecimal. It can also pad the result to a minimum length with leading zeros.
=BASE(number, radix, [min_length])What does BASE do?
The BASE function in Excel converts a decimal number (base 10) into a text string that represents that number in another base. You choose the target base with the radix argument, and you can optionally set a minimum length so the result is padded with leading zeros. For example, =BASE(10, 2) returns 1010 (the binary form of 10).
This matters because many technical and office tasks involve number systems other than decimal. IT asset tags, colour codes, memory addresses, and permission flags often use binary, octal, or hexadecimal. Instead of doing the conversion by hand or using a separate tool, you can keep everything in Excel and build it into your spreadsheets.
Imagine you are an office administrator preparing a device inventory. You have a list of decimal device IDs and need to print them as 8-bit binary labels for a hardware team. With BASE you can generate all the labels in one column, padded to exactly eight characters, and the result updates automatically if an ID changes.
When to use BASE
- Converting decimal numbers to binary for IT or networking labels.
- Creating hexadecimal colour codes or asset identifiers from decimal values.
- Producing octal or hexadecimal representations for programming or electronics tasks.
- Formatting numbers with leading zeros to a fixed width for reports or IDs.
- Teaching or demonstrating number bases in a classroom or training sheet.
- Preparing data for systems that expect non-decimal number formats.
BASE syntax
=BASE(number, radix, [min_length])| Argument | Required? | What to enter |
|---|---|---|
number | Required | The decimal number you want to convert. It must be a non-negative integer less than 2^53. Example: 10. |
radix | Required | The base you want to convert to. It must be an integer from 2 to 36. Example: 2 for binary, 16 for hexadecimal. |
min_length | Optional | The minimum number of characters in the returned text. If the converted number is shorter, leading zeros are added. It must be an integer from 0 to 255. Example: 8. |
What it returns: BASE returns a text string representing the number in the specified base. If min_length is provided, the string is padded with leading zeros to at least that length. The result is always text, even though it looks like a number.
BASE examples
1 Convert a decimal number to binary
This example converts the decimal number 10 to binary. The formula =BASE(B2, 2) takes the value in B2 (10) and the radix 2, and returns the text string 1010. Because no minimum length is given, no leading zeros are added. The result is the binary representation of 10.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Description | Number | |||
| 2 | Decimal value | 10 | 1010 | ||
| 3 |
2 Convert to hexadecimal with padding
Here we convert the decimal number 255 to hexadecimal and pad it to four characters. The formula =BASE(B2, 16, 4) uses 255 and radix 16, producing FF. Because min_length is 4, two leading zeros are added, giving 00FF. This is useful for fixed-width hex codes.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Description | Number | |||
| 2 | Decimal value | 255 | 00FF | ||
| 3 |
3 Convert to octal with minimum length
This example converts 64 to octal (base 8) and ensures the result is at least three characters long. The formula =BASE(B2, 8, 3) converts 64 to 100 in octal, which is already three characters, so no padding is needed. The result is the text 100.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Description | Number | |||
| 2 | Decimal value | 64 | 100 | ||
| 3 |
4 Generate 8-bit binary device labels
You have a list of device IDs and need 8-bit binary labels. The formula =BASE(B2, 2, 8) converts the ID in B2 to binary and pads it to eight characters with leading zeros. For ID 5, the binary is 101, padded to 00000101. This creates consistent labels for printing or scanning.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Device | ID | |||
| 2 | Router | 5 | 00000101 | ||
| 3 | Switch | 12 | |||
| 4 | Firewall | 255 | |||
| 5 |
5 Create hexadecimal colour codes from decimal values
A design team stores colour components as decimal numbers and needs hexadecimal codes. The formula =BASE(B2, 16, 2) converts the red component 255 to FF, padded to two characters. For 128, it returns 80. This lets you build hex colour codes like #FF80A0 by combining three BASE results.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Colour | Red value | |||
| 2 | Red | 255 | FF | ||
| 3 | Green | 128 | |||
| 4 | Blue | 160 | |||
| 5 |
Common BASE errors and how to fix them
| Error | Why it happens | How to fix it |
|---|---|---|
| #VALUE! | The number argument is negative, or radix is outside 2–36, or min_length is negative or greater than 255. | Ensure number is zero or positive, radix is between 2 and 36, and min_length is between 0 and 255. |
| #NUM! | The number argument is too large (2^53 or more) or not a valid number. | Use a smaller number or check that the cell contains a numeric value. |
| #NAME? | The function name is misspelled, e.g., =BASEX(...). | Type =BASE( and let Excel suggest the function, or correct the spelling. |
| #VALUE! (text in number) | The number argument refers to a cell containing text instead of a number. | Convert the text to a number or reference a numeric cell. |
Tips for using BASE
- Remember that BASE returns text, so if you need to do further calculations, convert it back with a function like
VALUEor keep the original number. - Use
min_lengthto create fixed-width codes for IDs, labels, or reports. - The
radixcan be any integer from 2 to 36, covering binary, octal, decimal, hexadecimal, and beyond. - To convert from another base back to decimal, use the
DECIMALfunction. - Combine BASE with
TEXTJOINor&to build composite codes such as hex colour strings. - Test your formula with a small number first to confirm the base and padding behave as expected.
Frequently asked questions
What is the maximum base that BASE can convert to?
The radix argument can be any integer from 2 to 36. Base 36 uses digits 0–9 and letters A–Z.
Can BASE convert negative numbers?
No. The number argument must be zero or positive. Negative numbers return a #VALUE! error.
Why does BASE return text instead of a number?
Because representations in other bases can include letters (for example, hexadecimal F), Excel returns a text string to preserve the characters.
How do I convert a binary or hexadecimal string back to decimal?
Use the DECIMAL function, for example =DECIMAL("1010", 2) returns 10.
Related functions
Every example on this page was recalculated by SheetSkill’s spreadsheet engine. BASE reference