StringMash.com

Hex to decimal converter

Hexadecimal to decimal and back, with each step shown.

Conversion
3 characters
Updates as you type
Swap for decimal to hex

Show the steps
  1. 1 × 16² = 1 × 256 = 256
  2. F × 16¹ = 15 × 16 = 240
  3. 4 × 16⁰ = 4 × 1 = 4
  4. Add them up: 256 + 240 + 4 = 500
Printable chart

Using the converter

Type a hex number and the decimal value appears as you type. Swap to go from decimal to hex. Several numbers can go in at once, separated by spaces, commas or new lines. Prefixes like 0x and 0b are fine, and so is the _ character used to group digits, as in 1001_1100. Numbers can be as long as you like and can be negative, but they have to be whole: there's no decimal point.

Show the steps opens the working under the answer, line by line, the same way you'd set it out on paper. It shows the first four numbers when there are several.

How to convert hex to decimal

Each place in a hex number is worth 16 times the place to its right: 1, 16, 256, 4096 and so on. Multiply each digit by its place value, reading A to F as 10 to 15, and add them up.

For 1F4: 1 × 256 is 256, F × 16 is 15 × 16, which is 240, and 4 × 1 is 4. Added together that's 500.

How to convert decimal to hex

Divide by 16 and note the remainder, then divide the answer by 16 again until it reaches 0. Write any remainder from 10 to 15 as a letter from A to F, and read the remainders from the bottom up.

For 500: 500 ÷ 16 is 31 remainder 4, 31 ÷ 16 is 1 remainder 15, which is F, and 1 ÷ 16 is 0 remainder 1. From the bottom up that's 1F4.

Hex colour codes

A web colour like #FF0099 is three hex numbers side by side: FF for red, 00 for green and 99 for blue. Each pair runs from 00 to FF, which is 0 to 255 in decimal. Put FF0099 in with a space after every two digits, FF 00 99, and you get 255 0 153, the same colour written as RGB.

THE FIRST 33 NUMBERS

Decimal, binary, octal and hex from 0 to 32

DecimalBinaryOctalHex
0000
1111
21022
31133
410044
510155
611066
711177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
16100002010
17100012111
18100102212
19100112313
20101002414
21101012515
22101102616
23101112717
24110003018
25110013119
2611010321A
2711011331B
2811100341C
2911101351D
3011110361E
3111111371F
321000004020

Questions

What is FF in decimal?

255. F is 15, so FF is 15 × 16 + 15.

What does 0x mean in front of a number?

It marks the number as hexadecimal in C and the many languages that copied it, so 0x10 is 16 rather than ten. The converter accepts it and ignores it.

Does it matter if I type capitals or lowercase?

No. ff and FF are the same number. The Hex letters setting picks which one you get back.