Hex Calculator

Convert between hexadecimal, decimal, and binary

Hex Calculator

Convert between decimal and hexadecimal

Hex Converter

Enter a decimal integer

Formula
Divide by 16 repeatedly

What is a Hex Calculator?

A Hex Calculator is a tool for working with hexadecimal numbers (also called hex), which use base 16 instead of base 10. Hexadecimal uses sixteen symbols: 0–9 and A–F, where A = 10, B = 11, C = 12, D = 13, E = 14, and F = 15.

Hex is widely used in computing because it's a compact way to represent binary data. Since 1 hex digit equals 4 binary bits, long binary values can be written much shorter in hex. For example: binary 1111 = hex F, and binary 10101100 = hex AC.

This Calculator Supports Multiple Conversions

  • Decimal → Hexadecimal -- convert base-10 numbers to base-16
  • Decimal → Binary -- convert base-10 numbers to base-2

Hex calculators are useful for converting between hex, decimal, and binary, working with colors in web design (e.g., #FF0000 for red), and understanding memory addresses, machine code, and other low-level computing concepts.

How to Use This Hex Calculator

  1. Enter a decimal number -- type any integer into the input field (e.g., 255)
  2. Click "Calculate" -- to convert the number
  3. Review both outputs -- the result shows the hexadecimal (base 16) and binary (base 2) representations simultaneously
  4. Try other values -- explore common values like 16, 128, 255, 256, or any decimal you need to convert

Tips:

  • Hex values often appear with a prefix like 0x (example: 0xFF). This calculator displays the raw hex digits without a prefix.
  • Hex uses only 0–9 and A–F. If you see an error, check for invalid characters.
  • Leading zeros (like 00FF) don't change the value, but can be useful when you want a fixed byte length.

Hex Formulas

Hex Place Value (Base 16)

Hex works like decimal place value, but with powers of 16:

value = Σ dᵢ × 16ⁱ (i = 0 to k)

Where each digit dᵢ can be 0–15 (0–9 or A–F)

Example: 1A₁₆ = 1×16¹ + 10×16⁰ = 16 + 10 = 26₁₀

Converting Decimal to Hex

Repeatedly divide by 16 and record remainders:

  1. Divide the number by 16
  2. Record the remainder (0–15, using A–F for 10–15)
  3. Divide the quotient by 16 and repeat until the quotient is 0
  4. Read the remainders from bottom to top

Hex to Binary Conversion Table

Each hex digit maps directly to a 4-bit binary group:

0

0000

1

0001

2

0010

3

0011

4

0100

5

0101

6

0110

7

0111

8

1000

9

1001

A

1010

B

1011

C

1100

D

1101

E

1110

F

1111

Hex Addition (Concept)

Hex addition follows the same idea as decimal addition, but carries happen at 16 instead of 10. If a digit sum is 16 or more, write the remainder and carry 1 to the next place.

Example Calculations

Example 1: Convert Hex to Decimal

Convert: 1A₁₆ to decimal

Calculation: 1×16 + 10 = 26

Result: 1A₁₆ = 26₁₀

Example 2: Convert Hex to Binary

Convert: 2F₁₆ to binary

Steps:

  • 2 = 0010
  • F = 1111

Result: 2F₁₆ = 00101111₂

Example 3: Convert Decimal to Hex

Convert: 255₁₀ to hex

Steps:

  • 255 ÷ 16 = 15 remainder 15
  • 15 in hex = F, remainder 15 = F

Result: 255₁₀ = FF₁₆

Example 4: Hex Addition

Add: A5₁₆ + 1C₁₆

Verify via decimal:

  • A5₁₆ = 10×16 + 5 = 165
  • 1C₁₆ = 1×16 + 12 = 28
  • 165 + 28 = 193
  • 193 ÷ 16 = 12 remainder 1 → C1

Result: A5₁₆ + 1C₁₆ = C1₁₆

Frequently Asked Questions

Why is hexadecimal used in computing?

Hex is a compact way to represent binary. Since 1 hex digit equals 4 bits, it's much easier to read and write than long binary strings, especially for memory addresses and machine data.

What do the letters A–F mean in hex?

They represent values 10 through 15: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.

What's the difference between hex and binary?

Binary is base 2 (0 and 1). Hex is base 16 (0–9 and A–F). Hex is often used as a shorthand for binary because it compresses 4 bits into 1 character.

What does "0x" mean in front of a number?

"0x" is a common prefix used in programming to indicate a hexadecimal number. For example, 0xFF means FF in hex (255 in decimal).

Why do hex values appear in colors like #FF0000?

In web design, colors are commonly represented as three hex pairs for Red, Green, and Blue (RGB). Each pair ranges from 00 to FF (0 to 255 in decimal). For example, #FF0000 is full red, no green, no blue.

Embed This Hex Calculator on Your Website

Want to add this hex calculator to your website? Get a custom embed code that matches your site's design and keeps visitors engaged.

Responsive design
Custom styling
Fast loading
Mobile optimized

What Is Hexadecimal?

Hexadecimal (base 16) uses digits 0–9 and letters A–F, where A=10, B=11, C=12, D=13, E=14, and F=15. It's compact by design — one hex digit represents exactly 4 binary bits — making it ideal for expressing binary data in a human-readable form. You'll see hex used constantly in programming, memory addresses, machine code, and anywhere large binary values need to stay readable without taking up a huge amount of space.

This calculator converts between hex, decimal, and binary instantly, and also handles hex arithmetic like addition and subtraction. It's an essential tool for web designers working with #RRGGBB color codes, programmers debugging memory addresses or register values, and anyone doing bitwise operations. Whether you're reading a CPU register dump or picking a background color for a website, hex is the language you need.

How to Use the Hex Calculator

  1. Enter a hexadecimal number using digits 0–9 and letters A–F, or enter a decimal number to convert from base 10.
  2. Select the conversion direction — hex to decimal, decimal to hex, or hex to binary.
  3. Click Calculate to process the conversion or arithmetic.
  4. Read all three base representations side by side: hexadecimal, decimal, and binary.

Hex Conversion Formulas

Hex to Decimal: multiply each digit by 16^position 1A3₁₆ = 1×16² + 10×16¹ + 3×16⁰ = 256 + 160 + 3 = 419 Decimal to Hex: divide by 16, collect remainders 255 ÷ 16 = 15 R15 (F), so 255₁₀ = FF₁₆ Hex digits: 0-9 = 0-9, A=10, B=11, C=12, D=13, E=14, F=15 Color codes: #RRGGBB — two hex digits each for Red, Green, Blue (0-255)

Each hex digit corresponds to exactly 4 binary bits (a "nibble"). Two hex digits make one byte, ranging from 00 to FF — that's 0 to 255 in decimal. This is why color channels in #RRGGBB each go from 00 (0) to FF (255).

Worked Examples

FF₁₆ = 255₁₀ — The Maximum Byte Value

FF in hex is the largest value that fits in a single byte (8 bits). In RGB color, FF means full intensity, so #FFFFFF is pure white (all three channels maxed out) and #000000 is pure black (all channels at 0).

Decoding a Hex Color Code: #1A2B3C

Split into three pairs: R = 1A₁₆ = 26₁₀, G = 2B₁₆ = 43₁₀, B = 3C₁₆ = 60₁₀. So #1A2B3C is a dark blue-gray with red=26, green=43, blue=60. This is exactly how CSS color pickers work under the hood.

1000₁₀ = 3E8₁₆

To convert 1000 to hex: 1000 ÷ 16 = 62 remainder 8, then 62 ÷ 16 = 3 remainder 14 (E), then 3 ÷ 16 = 0 remainder 3. Reading remainders bottom to top: 3E8. So one thousand in decimal is 3E8 in hexadecimal.

Frequently Asked Questions

Why do programmers use hexadecimal instead of decimal?
Because computers work in binary (base 2), and hex (base 16) maps cleanly onto binary — each hex digit is exactly 4 bits. That means a 32-bit memory address is 8 hex digits, much easier to read than 32 ones and zeros. Decimal doesn't have this clean relationship with binary, which makes it awkward for low-level work.
What does #FFFFFF mean in web colors?
#FFFFFF is pure white in CSS and HTML. The # prefix marks it as a hex color code. The six digits are three pairs: FF for red, FF for green, FF for blue. Each FF equals 255 in decimal, the maximum intensity for that color channel. All channels at maximum = white light.
How do you count in hexadecimal?
You count 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F — then roll over to 10 (which equals 16 in decimal). After 1F comes 20, after FF comes 100, and so on. It's the same carry logic as decimal counting, just with 16 symbols instead of 10.
What is a nibble?
A nibble is 4 bits — exactly half a byte. One hex digit represents one nibble. So a single byte (8 bits) needs exactly two hex digits. The word is a playful computing term: if a byte is a bite of data, a nibble is half that.
What is the difference between hex and binary?
Binary (base 2) uses only 0 and 1. Hex (base 16) uses 0–9 and A–F. They represent the same information, but hex is 4× more compact — every hex digit stands for 4 binary digits. Programmers often use hex as a shorthand for binary because it's much easier to read and type while still grouping cleanly into bytes and words.