Binary to Hex: Manual Conversion vs Online Translator
Binary and hexadecimal are two sides of the same coin. Every hex digit is exactly 4 bits. This makes converting between them fast once you learn the mapping. This guide covers the manual method, the lookup table you should memorize, and when an online binary-to-hex converter is the better option.
Why Hex Exists (and Why Programmers Prefer It)
Binary is hard to read. The byte 11111111 and the byte 11111110 look nearly identical at a glance. But one is 255 and the other is 254. In hex, that is FF vs FE — easy to spot the difference.
Hex is essentially shorthand. Every byte (8 bits) becomes two hex characters. Every 32-bit word becomes eight hex characters. You see hex in:
- Memory addresses in debuggers (e.g.,
0x7FFF5FB8) - Color codes in CSS (
#FF5733) - MAC addresses (
00:1A:2B:3C:4D:5E) - Binary file hex dumps
- Assembly language and machine code
The 4-Bit Grouping Method
The manual method takes three steps:
- Split the binary string into groups of 4 bits, starting from the right
- Pad the leftmost group with leading zeros if it is shorter than 4 bits
- Convert each 4-bit group to its hex equivalent
11010111 to hex:Step 1: Group from the right →
1101 0111Step 2: Both groups are 4 bits, no padding needed
Step 3:
1101 = D, 0111 = 7Result: D7
101001 to hex (note: 6 bits, not a multiple of 4):Step 1: Group from the right →
10 1001Step 2: Pad left group →
0010 1001Step 3:
0010 = 2, 1001 = 9Result: 29
The Only Table You Need: 4-Bit Binary to Hex
| Binary | Decimal | Hex | Binary | Decimal | Hex |
|---|---|---|---|---|---|
0000 | 0 | 0 | 1000 | 8 | 8 |
0001 | 1 | 1 | 1001 | 9 | 9 |
0010 | 2 | 2 | 1010 | 10 | A |
0011 | 3 | 3 | 1011 | 11 | B |
0100 | 4 | 4 | 1100 | 12 | C |
0101 | 5 | 5 | 1101 | 13 | D |
0110 | 6 | 6 | 1110 | 14 | E |
0111 | 7 | 7 | 1111 | 15 | F |
Print this table and tape it to your monitor. After a week of using it, you will not need it anymore. The patterns are regular and your brain picks them up fast.
Manual Conversion: Pros and Cons
When manual conversion works
- Converting a single byte or two: mental math is faster than opening a tool
- Reading a hex dump alongside source code: you need to understand what you are looking at
- Job interviews: binary-to-hex questions still show up in embedded systems and low-level roles
- Learning how data is actually stored: there is no substitute for doing it by hand a few times
When manual conversion breaks down
- Long binary strings: converting a 64-bit address by hand takes minutes and has a high error rate
- Batch conversions: debugging a network packet capture with dozens of fields
- Multi-format needs: you need decimal, text, and hex from the same binary input
- Non-standard bit lengths: a 14-bit field does not group cleanly into 4-bit nibbles
Programmatic Conversion: One-Liners in Every Language
Every programming language has a built-in way to convert binary strings to hex. Here are the ones you will use most often:
// JavaScript
parseInt("11010111", 2).toString(16); // "d7"
# Python
hex(int("11010111", 2)) # '0xd7'
// C (using strtol)
long val = strtol("11010111", NULL, 2);
printf("%lx", val); // d7
// Bash (using arithmetic expansion) printf '%x\n' "$((2#11010111))" # d7
Online Binary to Hex Converter: When Speed Matters
An online binary translator handles conversion in one paste. No console, no script file, no memorization needed. This matters when you are staring at a 200-line hex dump from Wireshark or a serial console and you need to extract a specific field right now.
Our BinTranslate binary-to-hex converter works in both directions. Paste binary, get hex. Paste hex, get binary and decimal and ASCII text. It shows all the representations side by side, which is what you actually want when troubleshooting.
Common Binary-to-Hex Conversion Pitfalls
Grouping from the wrong direction
Always group from the right, not the left. Grouping 101001 from the left gives 1010 01, which pads to 1010 0001 = A1. Grouping from the right gives 10 1001, pads to 0010 1001 = 29. The correct answer is 29. This mistake costs more debugging hours than any other single conversion error.
Forgetting hex letters are case-insensitive but convention matters
D7 and d7 represent the same value (215 decimal). In practice, uppercase is standard for hex dumps and memory addresses (0xFF). Lowercase is common in CSS colors (#ff5733). Both are valid. Do not mix cases within a single document; it makes it harder to scan.
Treating hex as decimal when reading it back
0x10 is 16, not 10. 0x64 is 100, not 64. This trips up beginners reading hex dumps. When you see hex digits, the rightmost column is 160 (ones), the next is 161 (sixteens), then 162 (two hundred fifty-sixes). This mirrors decimal but with base 16.
Binary-Hex-Decimal Quick Reference
| Binary | Hex | Decimal | Real-World Meaning |
|---|---|---|---|
00001010 | 0A | 10 | Line feed character |
00001101 | 0D | 13 | Carriage return |
00100000 | 20 | 32 | Space (most common byte) |
00110000 | 30 | 48 | Character '0' |
01000001 | 41 | 65 | Character 'A' |
01111111 | 7F | 127 | DEL character |
10000000 | 80 | 128 | Start of extended ASCII |
11111111 | FF | 255 | Max byte, subnet broadcast |