How to convert hex or binary to a number
✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)Read a hexadecimal, binary, or octal string back into a normal decimal number you can do math on — parsing color codes, register values, or bit flags.
The formula
| App | Formula | Notes |
|---|---|---|
| Excel (desktop) | =HEX2DEC(A2) | HEX2DEC for hexadecimal, BIN2DEC for binary, OCT2DEC for octal. The result is a real number you can calculate with. |
| Google Sheets | =HEX2DEC(A2) | Identical. All three *2DEC functions exist in Sheets. |
| LibreOffice Calc | =HEX2DEC(A2) | Identical. |
How it works
The *2DEC family is the inverse of the DEC2* converters: HEX2DEC("FF") returns 255, BIN2DEC("1010") returns 10, and OCT2DEC("17") returns 15. Unlike the DEC2* outputs, these return actual numbers, so you can add, compare, or format them straight away. The input can be a text string or an unquoted value, but note hexadecimal that starts with a letter (like "FF" or "A1") must be text or it will be read as a cell reference. For very large hex values beyond the ~10-digit limit, or to convert from an arbitrary base, use DECIMAL(text, radix) which handles bases 2 to 36. To convert directly between two non-decimal bases skip the round-trip and use functions like HEX2BIN or BIN2HEX. Going the other way — a number into a hex or binary string — is DEC2HEX / DEC2BIN (see convert-a-number-to-hex-or-binary).
Verified, not just documented
We ran =HEX2DEC("FF") in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 255 — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned 255 for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.
Functions used
HEX2DEC — see full Excel, Google Sheets & LibreOffice compatibility for each.