HEX2BIN Function

Converts a hexadecimal number to binary.

Category

Engineering

Available in

All versions, Microsoft 365

Returns

Binary text

Want to practice HEX2BIN in a real spreadsheet? Open a blank sheet in our Practice Sandbox and try it with live data, with the AI Excel tutor beside you. No Excel needed — just a free account.Try it free in the Sandbox

Overview

HEX2BIN converts a hexadecimal number into binary. Hexadecimal (base 16) uses 0–9 and then A–F for 10–15. Binary (base 2) uses only the digits 0 and 1.

Negative numbers use a fixed 10-character form called two's complement: the first digit acts as the minus sign. For example −1 is 1111111111 in binary, 7777777777 in octal and FFFFFFFFFF in hex. So HEX2BIN reads a 10-character hexadecimal value starting with 8–F as negative.

Syntax

=HEX2BIN(number, [places])

Arguments

ArgumentRequired?What it does
numberYesThe hexadecimal number to convert, as text or a number — up to 10 characters. Upper- or lower-case letters both work.
placesNoHow many characters to show, padding with leading zeros (e.g. 8 turns 101 into 00000101). Ignored for negative numbers.

Examples

Example 1 — Hexadecimal to binary

Each row converts the value in column A.

B2fx=HEX2BIN(A2)
AB
1HexBinary
2F1111
3B710110111
41FF111111111
5FFFFFFFE001000000000
=HEX2BIN(A2) Explain

Example 2 — Show a byte as eight bits

Places pads short answers.

=HEX2BIN("F",8) Explain

Returns 00001111.

Common mistakes

  • #NUM! The text isn't valid hexadecimal (for example a 2 in binary), it's longer than 10 characters, the answer doesn't fit in places, or a negative result is too big for the target base.
  • Values over 1FF. Binary is limited to 10 characters, so the largest positive hex value is 1FF (511). 200 returns #NUM!.

Notes

  • The answer is text, so it keeps leading zeros. Convert back with the matching ...2DEC function before doing maths with it.
  • Related functions: BIN2HEX, HEX2DEC, HEX2OCT.
Kyle Stott

Author

Kyle Stott

Certified Microsoft Excel Expert

Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.