# Hex to binary: one digit, four bits

> Why every hexadecimal digit expands to exactly four binary digits, a full digit table, colour-code and byte examples checked with the converter, and how the tool handles prefixes, case and odd-length input.

- Tool: [Hex to Binary Converter](https://toolsg.com/en/hex-to-binary)
- Language: en (available: en, zh, ms, ta)
- Last verified against official sources: 2026-10-18
- Source site: ToolSG — a planning guide, not official or financial advice. Cite the agencies listed under Sources.

## Key figures at a glance

| Fact | Value | Source |
| --- | --- | --- |
| Bits per hex digit | 4 (one digit covers 0 to 15) — So two hex digits make one byte, which is why hex is the usual way to write bytes. |  |
| Prefixes the tool strips | 0x, \x and # — Upper or lower case digits are both accepted; hex output elsewhere on the site is shown in upper case. |  |
| Unbroken input | Cut into pairs of digits — FFFF becomes two bytes. An odd number of digits in one run, such as 1F4, is rejected. |  |
| Colour codes | #RRGGBB is three pairs, each 00 to FF | [MDN CSS hex-color](https://developer.mozilla.org/en-US/docs/Web/CSS/hex-color) |

## Expanding hex to binary by hand

1. **Split the hex number into single digits** — 3F becomes 3 and F.
2. **Replace each digit with its four-bit pattern** — 3 is 0011 and F is 1111.
3. **Join the groups** — 0011 1111, which is 00111111 as one byte. Tools: [Hex to Binary Converter](https://toolsg.com/en/hex-to-binary)

## Why hex maps so neatly onto binary

16 is 2 to the power 4, so one hexadecimal digit carries exactly the information of four bits. There is no arithmetic to do: you look up each digit and write its four bits. That is also why programmers prefer hex over decimal for raw bytes.

| Hex | Binary | Hex | Binary |
| --- | --- | --- | --- |
| 0 | 0000 | 8 | 1000 |
| 1 | 0001 | 9 | 1001 |
| 2 | 0010 | A | 1010 |
| 3 | 0011 | B | 1011 |
| 4 | 0100 | C | 1100 |
| 5 | 0101 | D | 1101 |
| 6 | 0110 | E | 1110 |
| 7 | 0111 | F | 1111 |

## Worked examples

| Hex input | Binary output |
| --- | --- |
| `3F` | `00111111` |
| `A5` | `10100101` |
| `80` | `10000000` |
| `0x1F` | `00011111` |
| `F` | `00001111` |
| `1F 4` | `00011111 00000100` |
| `#4F46E5` | `01001111 01000110 11100101` |

The last row is a CSS-style colour: the pairs 4F, 46 and E5 are the red, green and blue bytes, so the converter shows each as its own eight-bit group. Every output above was produced by the converter.

## What the converter does

- It removes `0x`, `\x` and `#` wherever they appear, so `0xFF 0x0A` and `#FF8800` both work.
- Letters can be upper or lower case: `ff` and `FF` are the same.
- A single digit is treated as a whole byte, so `F` gives `00001111`. The padding is on the left, never on the right.
- Two or more digits in one run are cut into pairs: `FFFF` gives `11111111 11111111`. If the run is not an even length, such as `1F4`, the tool reports a length error instead of guessing.
- When you separate groups yourself, each group is read as one byte and must be 00 to FF. `100 1` fails because `100` is 256.

> **Tip:** To read `1F4` as one number, expand each digit with the table above: `1`, `F`, `4` is `0001 1111 0100`, and dropping the leading zeros gives `111110100` (500 in decimal). The converter would instead show `1`, `F` and `4` as three separate padded bytes.

## Common mistakes

- **An odd number of digits.** Add a leading zero (`01F4`) to make pairs, or separate the groups.
- **Typing the letter O for zero.** Letters outside A to F, such as O or G, are rejected with the offending token named.
- **Expecting one number from a long run.** The tool outputs bytes, not a single large integer.
- **Thinking `#` belongs to the value.** It is only the CSS marker and carries no bits.

## Related tools

- [Binary to hex](https://toolsg.com/en/binary-to-hex) is the reverse direction.
- [Hex to decimal](https://toolsg.com/en/hex-to-decimal) gives the 0 to 255 value of each byte.
- [Hex to octal](https://toolsg.com/en/hex-to-octal) re-groups the same bits in threes.
- [Hex to text](https://toolsg.com/en/hex-to-text) reads the bytes as characters.

## Frequently asked questions

**Is my data sent anywhere?**

No. The conversion runs entirely in your browser using JavaScript. Nothing you paste leaves your device, is logged, or is stored.

**How should I separate values?**

Spaces work, and so do commas, colons and semicolons. For binary, hex and octal you can also paste a single unbroken run of digits — it is split into bytes automatically.

**Does it handle emoji and non-English text?**

Yes. Text is treated as UTF-8, so accented characters, Chinese, Tamil and emoji all convert correctly. They simply take more than one byte each.

**Why did I get an error?**

The input contained a character that is not valid for the source format, a value above 255, or a run of digits that does not divide evenly into bytes. The message names the specific token so you can find it.


## Sources

- [MDN: CSS hex-color](https://developer.mozilla.org/en-US/docs/Web/CSS/hex-color) — Six-digit colours are three hexadecimal pairs between 00 and ff.
- [MDN: parseInt()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt) — Parsing a hexadecimal string, including the optional 0x prefix.
- [MDN: Number.prototype.toString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)
