BASE function

Converts a decimal number to text in another base (radix), useful for encoding, hexadecimal conversion, and system data transfers.

=BASE(number, radix, [min_length])

Generate a BASE formula

Describe what you need. The generator will reach for BASE where BASE is the right tool, and tell you when it is not.

How to get a better answer
  • Name your columns by letter and by header: "column F (Net Value)" beats "the amount column".
  • State every condition, including the negatives — "not cancelled" changes the formula's shape.
  • Say where the data starts if it is not row 1, and whether it will grow.
  • Check the settings above match your spreadsheet: the wrong argument separator is a syntax error on your machine.

Arguments

How BASE reads its arguments
numberrequiredradixrequiredmin_lengthoptionalBASE
ArgumentRequiredDescription
numberRequiredThe decimal number to convert to another base. Must be non-negative; BASE does not convert negative numbers and returns #NUM! if given a negative value.
radixRequiredThe base to convert to, from 2 through 36. Bases 2–10 use digits 0–9; bases 11–36 add letters A–Z. Radix outside this range returns #NUM!.
min_lengthOptionalOptional minimum length of the result string, padded with leading zeros if needed. Default is 1. Useful for fixed-width codes or identifiers.

Returns

A text string representing the number in the specified base.

Availability

Excel: All · Google Sheets: Supported

Worked examples

1. Encode an employee ID as binary

Employee IDNameDepartmentHire DateSalaryStatus
127AliceSales2021-03-1575000Active
255BobEngineering2019-07-2295000Active
384CarolHR2022-01-1068000Active
512DavidMarketing2020-11-0572000Inactive
1024EvaEngineering2018-09-18105000Active
=BASE(A2, 2)

Result: 1111111

Converts the employee ID 127 (in cell A2) to binary. The result 1111111 is useful for system-level integrations, bit manipulation, and any application requiring binary representation of employee numbers for encoding or data transfer.

2. Convert to hexadecimal with padding

Employee IDNameDepartmentHire DateSalaryStatus
127AliceSales2021-03-1575000Active
255BobEngineering2019-07-2295000Active
384CarolHR2022-01-1068000Active
512DavidMarketing2020-11-0572000Inactive
1024EvaEngineering2018-09-18105000Active
=BASE(A3, 16, 3)

Result: 0FF

Converts the employee ID 255 (Bob in row 3) to hexadecimal and pads the result to 3 characters with leading zeros. Hex codes like 0FF are compact, widely used in databases and color codes, and often required for system integration and memory address references.

3. Generate an alphanumeric code from a tier ID

Employee IDNameDepartmentHire DateSalaryStatus
127AliceSales2021-03-1575000Active
255BobEngineering2019-07-2295000Active
384CarolHR2022-01-1068000Active
512DavidMarketing2020-11-0572000Inactive
1024EvaEngineering2018-09-18105000Active
=BASE(A6, 36, 4)

Result: 00SG

Converts the ID 1024 (Eva's row) to base 36, which uses digits 0–9 and letters A–Z. The result 00SG is padded to 4 characters and is ideal for generating URL-safe, compact identifiers, inventory codes, and cross-system references that must fit strict length constraints or avoid special characters.

Common errors

Which BASE error are you seeing?
BASE returned an error#NUM!
Use a radix between 2 and 36. Common choices: 2 (binary), 8 (octal), 10 (decimal), 16 (hexadecimal), 36 (alphanumeric).
#VALUE!
Ensure both arguments are numeric values. If pulling from cells, verify they contain numbers, not text that looks like numbers.
#NUM!
Use ABS() to convert the number to its absolute value, or handle the sign separately before and after conversion.
ErrorWhy it happensHow to fix it
#NUM!The radix is less than 2 or greater than 36. BASE only supports bases from 2 (binary) through 36 (alphanumeric).Use a radix between 2 and 36. Common choices: 2 (binary), 8 (octal), 10 (decimal), 16 (hexadecimal), 36 (alphanumeric).
#VALUE!The number or radix argument is text or contains non-numeric data. BASE requires both arguments to be numbers.Ensure both arguments are numeric values. If pulling from cells, verify they contain numbers, not text that looks like numbers.
#NUM!The number argument is negative. BASE cannot convert negative numbers to other bases.Use ABS() to convert the number to its absolute value, or handle the sign separately before and after conversion.

Tips and when to use something else

  • BASE returns a text string, not a number—if you need to do math on the result or compare it numerically, remember it's text.
  • BASE is one-way: to reverse hexadecimal or binary strings back to decimal, use HEX2DEC or other conversion functions—BASE itself only converts to other bases.
  • For number formatting or display (adding commas, currency, decimals), use TEXT instead—BASE is specifically for base conversion, not formatting.
  • Common radix values: 2 (binary for system encoding), 8 (octal for Unix permissions), 16 (hexadecimal for databases and colors), 36 (alphanumeric for compact codes).

Frequently asked questions

What is BASE function used for?
BASE converts a decimal number to text in another base, such as binary (2), hexadecimal (16), or alphanumeric (36). It's essential for encoding, system integrations, and creating compact identifier codes.
How do I convert hexadecimal back to decimal?
BASE only converts to other bases. To reverse the conversion, use HEX2DEC for hexadecimal strings, or manually parse the string using SUMPRODUCT and FIND if working with other bases.
What base should I use for compact IDs?
Base 36 provides the most compact representation, using digits 0–9 and letters A–Z. It's ideal for creating short, URL-safe codes that must fit length constraints or avoid special characters.
Why is my BASE formula returning #NUM! or #VALUE! error?
BASE errors occur when: the radix is outside 2–36, the number is negative, or either argument is text instead of a number. Verify your inputs are numeric and the radix is in the valid range.

Need a different formula?

The full generator is not scoped to one function — describe any spreadsheet problem and it will pick.

Open the formula generator

Reviewed 2026-09-17