The BASE function converts a number into a text string written in a different number base, such as binary, octal, hexadecimal, or any base from 2 to 36. The syntax is BASE(value, base, [min_length]): the number you want to convert, the base you want it in, and optionally the minimum number of characters the result should have. It only works with the new Google Sheets engine, so if your file was created before the migration or you opened an old spreadsheet, the formula may not be recognised.

What You'll Need

  • A Google account with access to Google Sheets in a browser (sheets.google.com) or in the Google Sheets mobile app.
  • A spreadsheet created or converted to the current Google Sheets file format. Classic-format files do not support BASE.
  • A whole number to convert. BASE works on integers; decimals are truncated, so 7.9 becomes the same result as 7.
  • Knowledge of the base you want. Common choices are 2 (binary), 8 (octal), 10 (decimal, which gives you nothing new), 16 (hexadecimal), and 36 (0-9 then a-z).

Step-by-Step

  1. Open your spreadsheet in Google Sheets. Click the cell where you want the converted text to appear, for example cell B2.
  2. Type an equals sign to start a formula, then the word BASE in capitals: =BASE(. Google Sheets is not case-sensitive here, but capitals make formulas easier to read.
  3. Enter the number you want to convert. This can be a literal number such as 255, a cell reference such as A2, or another formula. Close the argument with a comma: =BASE(255,
  4. Enter the base. For hexadecimal type 16, for binary type 2, for octal type 8. The base must be a whole number between 2 and 36 inclusive. Add another comma if you want a minimum length: =BASE(255,16,
  5. Optionally type a minimum length, which pads the result with leading zeros. To make hexadecimal output always four characters, use 4. Then close the bracket and press Enter: =BASE(255,16,4) returns 00FF.
  6. Press Enter to commit the formula. The cell now shows text such as FF or 11111111. Press the cell again to edit it, or drag the small fill handle at the bottom-right corner to copy the formula down a column so each row converts its own value.
  7. Use an absolute reference if you plan to copy the formula sideways and the source number sits in a fixed column. For example, =BASE($A2,16,4) keeps column A fixed while the row changes.
  8. Wrap the formula in something useful if you need labels. =DECIMAL(BASE(A2,2),2) converts back to a number, and ="0x"&BASE(A2,16) prefixes hexadecimal output with the usual 0x notation.
  9. If you want the result as plain text rather than a live formula, select the cells, copy them, then use Edit > Paste special > Values only in the browser version. Note that menu labels can vary slightly between versions and regions, so look for the paste option that pastes values.

Common Mistakes

Treating the output as a number. BASE always returns text. You cannot add, subtract or sort numeric-style results reliably. Wrap the result in VALUE or DECIMAL if you need arithmetic.

Passing a base outside 2-36. =BASE(10,1) or =BASE(10,37) returns an error. Check that your base is a whole number inside that range.

Expecting fractions to work. BASE truncates decimals. 12.99 is converted as 12. Do your rounding first with ROUND or INT.

Using min_length to truncate. The third argument sets a minimum only. If a result is longer than min_length, it is shown in full, so min_length of 2 does not turn 1000 into 00.

Forgetting negative numbers. Negative values are not converted the way you might expect; BASE works cleanly with non-negative whole numbers. Sign-handling has to be built yourself, for example by checking the sign first and applying it afterwards.

Confusing BASE with DECIMAL. BASE converts from decimal out to another base; DECIMAL converts from another base back to decimal. They are the reverse of each other.

Tips

Remember that characters above 9 use letters: base 16 goes 0-9 then A-F, and base 36 goes 0-9 then A-Z. The uppercase A-Z mapping is fixed, so results are predictable.

Combine BASE with ARRAYFORMULA to convert a whole column in one formula, for example =ARRAYFORMULA(BASE(A2:A,16,4)), so you do not have to copy the formula down.

Use min_length to make fixed-width codes for IDs, colour hex values, or bit masks that line up neatly in a column. Four characters for hexadecimal and eight for binary are common choices.

Google Sheets also supports the number-base format through DECIMAL, HEX2DEC, BIN2DEC, OCT2DEC and their reverse cousins. Use BASE when you want one flexible formula that can handle any base; use HEX2DEC and similar functions when you need a simple fixed conversion for a common base.

Troubleshooting

If the formula shows a name error or is treated as plain text, the file is probably still in the old classic format, or the function name is misspelled. Check the spelling and, in the browser version, use File > Save as Google Sheets to move it to the current format before re-entering the formula.

If you see a numeric or argument error, check that you have exactly two required arguments and that the base is a whole number between 2 and 36. Extra commas create empty arguments that fail.

If the output looks wrong, verify whether your source value is really an integer and whether it is stored as a number, not text. Values imported with a leading apostrophe are text and will not convert; retype them or use VALUE to coerce them.

If the result seems unexpectedly short, remember there is no padding unless you supply min_length, and padding never truncates.

If a copied formula gives the same answer in every row, your source reference is probably absolute when it should be relative, or the reverse. Check for stray dollar signs.

If nothing resolves it, create a fresh test spreadsheet in the current format and try =BASE(255,16,4) in an empty cell. If that works, the problem is in your source data or file format, not the function.

Frequently Asked Questions

What does the BASE function do in Google Sheets?

It converts a decimal number into a text string in another number base, such as binary, octal or hexadecimal, with an optional minimum length padded by leading zeros.

Which bases can BASE handle?

Any whole-number base from 2 to 36. Digits above 9 are shown as letters, so base 16 uses A-F and base 36 uses A-Z.

Does BASE return a number or text?

It returns text. If you need to do arithmetic, convert it back with DECIMAL first, or wrap the result in VALUE.

How do I get leading zeros?

Use the optional third argument, min_length. For example, =BASE(15,2,8) returns 00001111. It only pads; it never removes digits.

Can I convert a whole column at once?

Yes. Use ARRAYFORMULA around the formula and a range as the value, such as =ARRAYFORMULA(BASE(A2:A,16,4)).

What is the difference between BASE and DECIMAL?

BASE converts a decimal number out to another base. DECIMAL converts a number in another base back into decimal, so the two are opposites.