Skip to content

Hex to Decimal Converter

Convert hex to decimal or decimal to hex — instant results, free, and fully browser-based.

Last updated:

Mode: Hex → Decimal

Why hex exists at all

Computers think in binary. A byte is eight bits, and eight bits is a clumsy number to write out — a single byte like 10110110 is already hard to parse at a glance, and a 32-bit register value is nearly unreadable. Hexadecimal (base 16) compresses the same data into half the length without losing any of the information.

The trick is that 16 is exactly 2⁴, so every hex digit maps cleanly to 4 bits. The byte above splits into 1011 0110, which is B and 6 — a two-character hex representation (B6) for eight bits. Once you know that A=10, F=15, you can read or write binary in your head.

That's why hex shows up everywhere programmers touch raw bytes: memory addresses, machine code, network protocols, file headers, crypto hashes, MAC addresses, and color codes. Hex is the shortest human-friendly way to write "exactly these bits".

The math: converting hex to decimal by hand

Each hex digit is worth 16 times the digit to its right, the same way each decimal digit is worth 10 times the one to its right. To convert 2F:

  • The F is in the ones place, worth 15 × 1 = 15.
  • The 2 is in the sixteens place, worth 2 × 16 = 32.
  • Total: 32 + 15 = 47.

For larger values the pattern extends — a four-digit hex like 1A2B has places worth 4096, 256, 16, and 1. You almost never do it by hand past a single byte, which is exactly what the converter is for. But understanding the principle helps you read hex without translating every time.

A handful of round values are worth memorizing: 0xFF = 255 (max byte), 0x80 = 128 (high bit set), 0x20 = 32 (space in ASCII), 0xFFFF = 65535 (max 16-bit value), 0xDEADBEEF = a very famous debug marker.

Hex in the wild — where you'll actually see it

  • CSS colors. #FF5733 is three bytes — red, green, blue — each a 0-255 intensity. Our Color Converter handles the full pipeline between hex, RGB, and HSL.
  • Memory addresses. A debugger or crash log that prints 0x00007ffee... is pointing at a 64-bit pointer. Addresses are always hex in system software because byte boundaries matter.
  • Error codes. Windows error codes, HRESULT values, and kernel panics print in hex so bit flags can be spotted at a glance. 0x80070005 has meaning in the high and low halves that would be invisible in decimal.
  • Crypto hashes. SHA-256 outputs are always printed as 64 hex characters. Our Hash Generator emits them the same way.
  • MAC addresses and UUIDs. Ethernet MACs (aa:bb:cc:dd:ee:ff) are six bytes in hex; UUIDs are 16 bytes formatted with hyphens.

Prefix conventions: 0x, #, and nothing

Hex values are usually written with a prefix that tells you the base. Different contexts use different prefixes:

  • 0x — C, C++, Java, JavaScript, Python, Go, Rust, and basically every modern language. This is the most common prefix in code.
  • # — CSS color codes and some config files. Not legal in code.
  • $ — assembly, old Pascal dialects, 6502 and 68000 assembler. Rare outside retro computing.
  • No prefix — hexdump, many command-line tools, HTTP status-code tables. Only works when the context tells you it's hex.

This converter accepts any of those — 0xFF, #FF, and FF all produce 255. Case doesn't matter either. If you need a different base entirely, use our Number Base Converter for arbitrary bases 2-36.

Related conversion tools on CodeBoxTools

  • Binary to Decimal — the same idea for base 2, with support for fixed bit widths and two's complement.
  • Number Base Converter — arbitrary bases from 2 to 36, including octal and base-36 short IDs.
  • Color Converter — HEX, RGB, HSL, HSV all at once when you're working with hex color codes.
  • Hash Generator — produces SHA-256, SHA-1, and other hashes as hex strings.

Frequently Asked Questions

What is hexadecimal?
Hexadecimal (hex) is a base-16 number system using digits 0-9 and letters A-F. It's widely used in computing to represent binary data in a human-readable format.
Can I convert decimal to hex?
Yes. Use the swap button to toggle the conversion direction between hex-to-decimal and decimal-to-hex.
Does this support large numbers?
Yes, up to JavaScript's safe integer limit (2^53 - 1). For larger values, precision may be lost.
What does the `0x` prefix mean?
`0x` is a programming-language convention (C, JavaScript, Python) that marks a literal as hexadecimal. It is not part of the number itself. This tool accepts hex with or without the prefix.
How do I convert hex color codes?
Hex colors like `#FF5733` are three pairs of hex digits for red, green, and blue. Each pair converts to a 0–255 decimal value. Use our Color Converter for full RGB/HSL output.
Is hex case-sensitive?
No. `FF`, `ff`, and `Ff` all represent the same value (255). Uppercase is often used by convention for readability, but lowercase is equally valid.

Related Tools