Hex to 7-Segment Display Converter
Convert hex digits into their 7-segment display encoding — the standard segment byte for each digit 0-F, common-cathode, active-high.

Built by
Swapnil SanghviFull-Stack Web Developer & WordPress Developer
Swapnil Sanghvi is a full-stack web and WordPress developer, UI designer, and full-time freelancer who builds and maintains Hex Calculator.
Further reading: hex — Stack Overflow
How 7-Segment Encoding Works
Each hex digit (0-F) needs a specific combination of the 7 segments lit to display it. That combination is packed into a single byte, one bit per segment — this calculator uses the common gfedcba bit order, where bit 0 (the least significant bit) controls segment a.
Full Hex Digit Reference
| Digit | Segments lit | Byte (gfedcba) |
|---|---|---|
| 0 | a b c d e f | 0x3F |
| 1 | b c | 0x06 |
| 2 | a b d e g | 0x5B |
| 3 | a b c d g | 0x4F |
| 4 | b c f g | 0x66 |
| 5 | a c d f g | 0x6D |
| 6 | a c d e f g | 0x7D |
| 7 | a b c | 0x07 |
| 8 | a b c d e f g | 0x7F |
| 9 | a b c d f g | 0x6F |
| A | a b c e f g | 0x77 |
| b | c d e f g | 0x7C |
| C | a d e f | 0x39 |
| d | b c d e g | 0x5E |
| E | a d e f g | 0x79 |
| F | a e f g | 0x71 |
Where Hex to 7-Segment Actually Comes Up
Writing a Lookup Table for an Embedded Display Driver
Microcontroller code that drives a 7-segment display directly (without a dedicated driver chip) needs a lookup table exactly like this one to convert each digit to its segment byte.
const uint8_t digitTable[16] = { 0x3F, 0x06, ... }
Debugging an Incorrectly Displayed Digit
When a 7-segment display shows the wrong pattern, comparing the byte your code is sending against the correct value from this table quickly identifies whether the bug is in the lookup table or elsewhere.
compare sent byte to expected 0x5B for digit 2
Converting Between Common-Cathode and Common-Anode
Taking a value from this common-cathode reference table and inverting it (bitwise NOT) to get the correct active-low value for a common-anode display.
common-anode byte = ~(common-cathode byte)
Why Use This Calculator Instead of Doing It by Hand
- Converts a whole string of hex digits at once, not just one at a time
- Full reference table alongside the calculator for looking up any digit directly
- Runs entirely in your browser — nothing you type gets sent anywhere
- Saves re-deriving the segment pattern for each digit from scratch
Limitations
- Uses one specific encoding convention (common-cathode, active-high, gfedcba bit order) — other conventions exist, and common-anode displays need the bitwise inverse of these values.
- Doesn't control the decimal point segment — most displays have an 8th segment for that, controlled separately from this table.
Frequently Asked Questions
What do the segment letters (a-g) refer to?
The 7 individual LED or LCD segments that make up a digit display, conventionally labeled a through g — a is the top segment, b and c are the upper-right and lower-right, and so on around the digit, with g being the middle segment.
What encoding convention does this use?
Common-cathode, active-high, with segments packed into a byte in gfedcba bit order (segment a is the least significant bit) — the most widely published convention in embedded systems references, though other conventions do exist.
What's the difference between common-cathode and common-anode?
Common-cathode displays light a segment when its control bit is 1 (active-high); common-anode displays are wired the opposite way, so lighting a segment needs a 0 (active-low) — a common-anode driver needs the bitwise inverse of this table's values.
Why do letters like B and D appear lowercase on a 7-segment display?
A 7-segment display physically can't distinguish uppercase B from 8, or uppercase D from 0 cleanly, so hex displays conventionally render b and d in a lowercase-style segment pattern to stay visually distinct from 8 and 0.