Hex to Binary Converter

Converts a plain hexadecimal string into binary by mapping each hex digit individually to its zero-padded 4-bit form, preserving leading zeros per digit exactly as a real bit pattern would appear. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

Every hex digit corresponds to exactly 4 bits, which makes hex-to-binary conversion mechanical but easy to get subtly wrong if you convert the whole value at once instead of digit by digit.

This tool converts each hex digit to its own zero-padded 4-bit binary group and concatenates them, so the result always has the correct, predictable length.

What Is Hex to Binary Converter?

A hexadecimal-to-binary converter that maps each hex digit (0-9, A-F) to its exact 4-bit binary equivalent and joins the results together, preserving every leading zero per digit.

It's the direct inverse of Binary to Hex Converter, and pairs well with Hex to Integer Converter when you need to inspect an actual bit pattern's individual bits.

How Hex to Binary Converter Works

The input is trimmed, an optional 0x/0X prefix is stripped, and the remaining characters are validated as hex digits (case-insensitive, no sign allowed).

Each validated hex digit is converted individually via `parseInt(digit, 16).toString(2).padStart(4, "0")`, and the resulting 4-bit strings are concatenated in order.

When To Use Hex to Binary Converter

Use it whenever you need to see the exact bit pattern behind a hex value, for debugging binary protocols, flag registers, checksums, or bitmask constants.

If you need the decimal magnitude instead of a bit pattern, use Hex to Number Converter or Hex to Decimal Converter.

Features

Advantages

  • Preserves every leading zero bit within each hex digit, unlike a naive whole-value binary conversion.
  • Output length is always exactly 4 bits per input hex digit, making it predictable and easy to visually align.
  • Accepts an optional 0x prefix or bare hex digits interchangeably.

Limitations

  • Cannot interpret hex as a signed value; a leading minus sign is rejected rather than applied to the output.
  • Does not group or space the output into bytes or nibbles automatically; it's a single continuous binary string.

Examples

Converting a byte value

Input

2F

Output

00101111

Hex 2 maps to 0010 and hex F maps to 1111; concatenated, this gives 00101111.

Preserving a leading zero digit

Input

01

Output

00000001

Hex 0 maps to 0000 and hex 1 maps to 0001, keeping all 8 bits instead of dropping the leading zeros a whole-value conversion would drop.

Best Practices & Notes

Best Practices

  • Use this tool whenever the exact bit-for-bit pattern matters; a whole-value binary conversion can silently drop leading zero bits.
  • Group the output into bytes (8 characters) mentally or with a text editor if you're comparing it against byte-oriented documentation.

Developer Notes

After validating the hex string via the shared `parseHexString` helper (no sign allowed), each digit character is mapped with `parseInt(digit, 16).toString(2).padStart(4, "0")` and the results are joined, which is what preserves per-digit leading zeros that a single `BigInt(...).toString(2)` call on the whole value would lose.

Hex to Binary Converter Use Cases

  • Inspecting the exact bit pattern of a hex flag register or bitmask constant
  • Debugging binary protocol messages by expanding hex bytes into their bit-level form
  • Teaching or verifying the relationship between hex digits and 4-bit binary groups

Common Mistakes

  • Assuming a whole-value hex-to-binary conversion preserves leading zeros; converting per-digit (as this tool does) is required for that.
  • Expecting a signed interpretation from a hex value with its top bit set; this tool never applies any sign logic.

Tips

  • Round-trip through Binary to Hex Converter to double-check a conversion.
  • If you need the decimal value instead, Hex to Decimal Converter performs the same input validation with a different output format.

References

Frequently Asked Questions