Skip to content
Free tool

Convert hex to decimal and binary

Convert hex to decimal, binary to decimal and back: the converter displays every number live in binary, octal, decimal and hexadecimal, with step-by-step calculations. For example, the hex number FF becomes 255 in decimal, 11111111 in binary and 377 in octal. Free, no sign-up required; conversion runs directly in your browser.

Built by Luca Stanek

  • Binary, octal, decimal, hex
  • With step-by-step calculations
  • Two's complement up to 64 bits
  • Runs in the browser

Writing code? Test it on your own VPS.

Sign

Example values

Bits

8 bits; click a bit to toggle it

70

Calculation steps from Hexadecimal to

From Hexadecimal to decimal: multiply each digit by its place value

  1. F × 161 = 15 × 16 = 240
  2. F × 160 = 15 × 1 = 15
  3. 240 + 15 = 255

Result in Decimal: 255(Base 10)

Example result

How the hex-to-decimal converter works

Enter a number in one base and get it in all the others. Here’s an example using FF: your result depends on your input.

Example · Input: FF (hexadecimal)

Input

Hexadecimal
FF
Base 16, also written as 0xFF

Output

Decimal
255
15 × 16 + 15 × 1
Binary
1111 1111
A full byte, all 8 bits set
Octal
377
8-bit two's complement
-1
Read as a signed number, FF is −1

Features

More than a hex-to-decimal calculator

One tool for every number base, from computer science classes to debugging.

All number bases at once

Type in any field: decimal, binary, hexadecimal, octal, and a base of your choice from 2 to 36 update immediately, without choosing a conversion direction.

Step-by-step calculation

Place values, repeated division, and the shortcut using bit groups: see how the result is calculated and work through it yourself for homework or exams.

Two's complement with 8 to 64 bits

Negative numbers such as −1 appear as bit patterns like FF, FFFF, or FFFFFFFF. The calculator can also read a bit pattern as a signed number.

Clickable bits

Each bit has its own switch at its position. Click to set or clear it; all fields update immediately.

Arbitrarily large numbers

The converter calculates exactly with up to 1,024 digits, even far beyond 64 bits, with no rounding or scientific notation.

Prefixes and clear error messages

0x, 0b, 0o, # and spaces are supported. If a digit is invalid, the calculator shows its position; if a prefix is invalid, it points you to the correct field.

How it works

How to convert hex to decimal and between other number bases

Three steps from number to calculation, with no sign-up.

Step 1

Enter a number in any field

Enter the number in its original base: a hex number in the Hexadecimal field, a binary number in the Binary field. Prefixes such as 0x, 0b and 0o, and spaces between digits, are allowed.

Step 2

View results in every base

All other fields update instantly: decimal, binary, hexadecimal, octal and a base of your choice. For negative numbers, choose two’s complement with 8 to 64 bits.

Step 3

Follow and copy the calculation steps

Choose the target base under Calculation steps and follow each step. Copy a value with one click or share a link containing your number.

Calculate by hand

Converting number bases: the methods

Six methods to help you convert any number without a calculator. All examples were calculated with the converter above.

Convert hex to decimal

Each position is a power of 16. Multiply each digit by its place value and add the results. A through F represent 10 through 15.

2 × 161 = 32

A × 160 = 10

2A = 32 + 10 = 42

Convert binary to decimal

Each position is a power of 2. Add the place values of all the 1s, counting from the right: 1, 2, 4, 8, 16, 32, and so on.

1×25 + 0×24 + 1×23 + 0×22 + 1×21 + 0×20

101010 = 32 + 8 + 2 = 42

Convert decimal to binary

Keep dividing the number by 2 and write down each remainder. Read the remainders from bottom to top to get the binary number.

42 ÷ 2 = 21 remainder 0

21 ÷ 2 = 10 remainder 1

10 ÷ 2 = 5 remainder 0

5 ÷ 2 = 2 remainder 1

2 ÷ 2 = 1 remainder 0

1 ÷ 2 = 0 remainder 1

42 = 101010

Convert decimal to hex

Use the same remainder method with 16: divide by 16, write each remainder as a hex digit (10 = A through 15 = F), then read the remainders from bottom to top.

2026 ÷ 16 = 126 remainder 10 (A)

126 ÷ 16 = 7 remainder 14 (E)

7 ÷ 16 = 0 remainder 7

2026 = 7EA

Binary to hex and hex to binary

Four bits make exactly one hex digit. Split the binary number into groups of four from the right and write the corresponding digit for each group. For octal, use groups of three.

0010 → 2

1010 → A

101010 = 2A

Negative numbers in two's complement

Write the absolute value using a fixed bit width, invert all the bits, and add 1. If the highest bit is 1, the number is negative.

Magnitude 42: 00101010

Inverted: 11010101

Plus 1: 11010110 = D6

Conversion table

Table: decimal, binary, hex, and octal from 0 to 31

The first 32 numbers in all four bases, plus the limits you’ll often encounter when programming.

DecimalBinaryHexadecimalOctal
00000 0000000
10000 0001011
20000 0010022
30000 0011033
40000 0100044
50000 0101055
60000 0110066
70000 0111077
80000 10000810
90000 10010911
100000 10100A12
110000 10110B13
120000 11000C14
130000 11010D15
140000 11100E16
150000 11110F17
DecimalBinaryHexadecimalOctal
160001 00001020
170001 00011121
180001 00101222
190001 00111323
200001 01001424
210001 01011525
220001 01101626
230001 01111727
240001 10001830
250001 10011931
260001 10101A32
270001 10111B33
280001 11001C34
290001 11011D35
300001 11101E36
310001 11111F37

Important limits

DecimalHexadecimalMeaning
1277FLargest signed 8-bit number
255FFLargest number in one byte
10244002 to the power of 10, one kilobyte in binary
327677FFFLargest signed 16-bit number
65535FFFFLargest 16-bit number, also the highest port number
21474836477FFFFFFFLargest signed 32-bit number
4294967295FFFFFFFFLargest 32-bit number, also an IPv4 address
92233720368547758077FFFFFFFFFFFFFFFLargest signed 64-bit number

Practical examples

Where you’ll encounter hex, binary and octal

Three common situations where you need to convert between number bases, with examples from the converter.

Hex to decimal in code

In Python, int("ff", 16) converts a hex number to decimal; in JavaScript, parseInt("ff", 16) does the same. Both return 255 for ff. The converter above shows you the steps.

int("ff", 16) = 255

parseInt("ff", 16) = 255

Hex colour codes

A colour code such as #FF8800 consists of three hex pairs for red, green and blue, each ranging from 00 to FF, or 0 to 255. Enter a pair in the Hexadecimal field to see its decimal value.

FF = 255

88 = 136

00 = 0

Convert whole colors with the Color Picker

Octal in file permissions

Linux file permissions such as 755 are octal numbers: each digit represents exactly three bits. Enter 755 in the Octal field to see the bits and decimal value.

7 → 111

5 → 101

5 → 101

755 = 493

Calculate file permissions with the chmod calculator

Explore more

More tools

FAQ

Frequently asked questions about the hex to decimal converter

Quick answers about hex, binary, decimal, octal, and two's complement.

Enter a number in one base and immediately get it in all the others. The hex number FF becomes 255 in decimal, 11111111 in binary, and 377 in octal. The calculator also shows the calculation and, if the number fits in 64 bits, every individual bit.

Each position in a hex number is a power of 16, counting from the right: 1, 16, 256, 4096. Multiply each digit by its place value and add the results; the letters A through F represent 10 through 15. This makes 2A equal to 2 × 16 + 10 × 1 = 42.

Add the place values of all the 1s. Counting from the right, they are 1, 2, 4, 8, 16, and so on. So the binary number 1101 is 8 + 4 + 1 = 13. Enter the binary number in the Binary field above to see each position in the calculation.

Keep dividing the number by 2 and note each remainder until you reach 0. Read the remainders from bottom to top to get the binary number: 42 becomes 101010. Converting decimal to octal works the same way with 8, and decimal to hex with 16.

Use repeated division by 16. Each remainder from 10 to 15 becomes a letter from A to F. Dividing 2026 by 16 gives 126 remainder 10 (A); 126 divided by 16 gives 7 remainder 14 (E); 7 divided by 16 gives 0 remainder 7. Reading from bottom to top, 2026 is 7EA.

No need to go through decimal: four bits make exactly one hex digit. Split the binary number into groups of four from the right and replace each group with its digit: 1010 1111 becomes AF. To go the other way, write each hex digit as four bits. The same works for octal using groups of three.

This is how computers store negative integers. With a fixed bit width, invert all the bits of the absolute value and add 1. With 8 bits, −1 becomes 11111111, or FF, and −128 becomes 10000000. Select two's complement and the bit width above to see the bit pattern and calculation.

Unsigned, FFFFFFFF is 4294967295, the largest 32-bit number. In 32-bit two’s complement, the same bit pattern represents -1. Select Two’s complement and 32 bits above, then enter FFFFFFFF in the Hexadecimal field: the Decimal field will show -1, while the bits will also show the unsigned value.

Integers in any base from 2 to 36, exact up to 1024 digits—even far beyond 64 bits. The prefixes 0x, 0b and 0o, as well as # for hex, are recognised. Spaces, underscores and apostrophes between digits are ignored. The converter doesn’t support fractional numbers; entering a comma or period in the Decimal field displays a notice.

The Binary Translator converts text—letters and characters—to binary code and back. This converter converts numbers between number bases: the number 65 becomes 1000001. To write a word in binary, use the Binary Translator. To convert a number, you're in the right place.

Any more questions?

Contact Support
More than just calculations

Your code needs a server that's always running

A ZAP-Hosting VPS reliably gets your application, bot, or API online, with root access and full control.

4.4/5 Trustpilot32,000+ Active serversSince 2010

No setup. No risk. Online in seconds.

Flexible TermCancel anytimeOnline in 60 seconds

Looking for more tools? View all developer tools