Hex converter

What to convert
base 16

Try
base 10

base 8

base 2

Hex digits
2
Bit length
8
Bytes
1
Sign
Positive

Digit by digit

Each place is worth 16 times the one to its right
DigitValuePlace valueDigit × placeBits
F15161 = 1615 × 16 = 2401111
F15160 = 115 × 1 = 151111

240 + 15 = 255

Signed and unsigned

The same bits read as unsigned and as two's complement
WidthHex patternUnsignedSigned
8-bitFF255−1
16-bit00FF255255
32-bit0000 00FF255255
64-bit0000 0000 0000 00FF255255

Byte order

Lowest memory address first

Stored as a 8-bit value, 1 byte.

Order+0
Big-endianFF
Little-endianFF
Guide

How to convert hex by hand

  1. Write the place value above each digit, starting with 1 on the right and multiplying by 16 as you move left: 1, 16, 256, 4,096.
  2. Swap any letters for their values: A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15.
  3. Multiply each digit by its place value and add the results. 1F4 is 1 × 256 + 15 × 16 + 4 × 1 = 500.

Worked example

Converting 0x1F4 to decimal, digit by digit:

DigitValuePlace valueResult
11162 = 256256
F15161 = 16240
44160 = 14

256 + 240 + 4 = 500

  • Going the other way, divide by 16 and read the remainders from last to first. 500 leaves 4, then 15 (F), then 1, so it's 1F4.
  • The same hex can stand for two numbers. FF is 255 unsigned, but −1 as a signed 8-bit value.
  • In Text mode each pair of hex digits is one UTF-8 byte, so 48 69 spells Hi.

Hex digits in binary

4 bits per digit
HexBinaryDecimal
000000
100011
200102
300113
HexBinaryDecimal
401004
501015
601106
701117
HexBinaryDecimal
810008
910019
A101010
B101111
HexBinaryDecimal
C110012
D110113
E111014
F111115
Learn

Hexadecimal conversion explained

Place values in base 16, signed hex, byte order and how hex spells out text.

Programmers write bytes in hexadecimal because it's compact, and a hex converter translates those values into decimal, binary and octal, or turns hex bytes into readable text. This one works in both directions: type into any field and the others update, or switch to Text to convert text to hex and hex to text. Below you'll find how base 16 works, how to convert hex to decimal and decimal to hex by hand, and what signed values and byte order mean.

How hexadecimal works

Hexadecimal, or hex, is base 16. It needs sixteen digit symbols, so after 0 to 9 it uses the letters A to F for the values 10 to 15. Each position is worth sixteen times the one to its right: 1, 16, 256, 4,096, 65,536 and so on. Because 16 is 2⁴, every hex digit stands for exactly four bits, and two hex digits make one byte. That's why FF, the largest two-digit hex number, is 255, the largest value a byte can hold.

How to convert hex to decimal

Multiply each digit by its place value and add the results. For 2F, that's 2 × 16 + 15 × 1 = 47. Longer numbers work the same way. 7FFF is 7 × 4,096 + 15 × 256 + 15 × 16 + 15 × 1, which is 28,672 + 3,840 + 240 + 15 = 32,767, the largest signed 16-bit integer. The Digit by digit table in this hex converter lists every digit, its place value and what it adds, so you can check each step of a hex to decimal conversion. For a single conversion with a shortcut method and a table of common values, see the hex to decimal converter.

How to convert decimal to hex

Divide by 16 and keep the remainder, then divide the quotient again until it reaches zero. Read the remainders from last to first. For 1,000: 1,000 ÷ 16 = 62 remainder 8, 62 ÷ 16 = 3 remainder 14 (E), and 3 ÷ 16 = 0 remainder 3, so 1,000 is 3E8. You can also go through binary. 1,000 is 1111101000, and grouping the bits in fours from the right gives 11 1110 1000, which is 3, E and 8. The hex to binary converter and the binary to hex converter show that grouping digit by digit, and the decimal to hex converter lists every division.

Signed hex and two's complement

Hex itself has no sign. Inside a computer, though, a fixed-width integer can be read as unsigned or as signed in two's complement, where the top bit counts as negative. In 8 bits, FF is 255 unsigned but −1 signed, and 80 is 128 or −128. A quick rule: if the first digit of a full-width value is 8 or higher, the top bit is set and the signed reading is negative. To find it, subtract 2 to the power of the width. DEADBEEF is 3,735,928,559 unsigned, and 3,735,928,559 − 4,294,967,296 = −559,038,737 as a signed 32-bit number. The Signed and unsigned table shows both readings at 8, 16, 32 and 64 bits, and the two's complement calculator explains the encoding bit by bit.

Big-endian and little-endian

A number wider than one byte has to be stored as several bytes, and there are two orders for them. Big-endian stores the most significant byte first, so the 32-bit value DEADBEEF is laid out as DE AD BE EF. Little-endian stores the least significant byte first: EF BE AD DE. Network protocols use big-endian, while x86 and most ARM systems are little-endian. This matters when you read a hex dump: the bytes F4 01 in a little-endian file are the 16-bit value 01F4, or 500. The Byte order table shows both layouts for every value.

Hex to text and text to hex

Text is stored as bytes, and hex is the usual way to show them. In ASCII, every character is one byte: A is 41, a is 61, the digit 0 is 30 and a space is 20, so 48 65 6C 6C 6F is hex for Hello. That's all hex to ASCII conversion is. Characters outside ASCII take more bytes in UTF-8: é is C3 A9, € is E2 82 AC and the emoji 👋 is F0 9F 91 8B. In Text mode this hex converter encodes and decodes UTF-8, and it warns you when bytes such as a lone E9 aren't valid UTF-8.

Hex notation you'll meet

  • 0x prefix. C, Java, JavaScript, Python and most other languages write hex as 0xFF.
  • Hash sign. CSS colors such as #FF8000 are three bytes: 255 red, 128 green and 0 blue.
  • Escapes. Strings use \x41 for a single byte, and URLs use percent signs, as in %20 for a space.
  • Code points. Unicode writes characters in hex, so U+0041 is the letter A.

The converter accepts a 0x prefix, a minus sign, and spaces or underscores between digits. In Text mode you can paste bytes separated by spaces, commas or colons, or written with 0x, \x or %.

Shortcuts in the hex converter

  • Press ↑ or ↓ in any field to step the value by 1, or hold Shift to step by 16.
  • The Uppercase switch changes how the letters A to F are shown. Input isn't case-sensitive.
  • Values of any length convert exactly, with no rounding, so 64-bit and larger numbers are safe.
  • For text as 0s and 1s instead of hex, use the text to binary converter.

Hex is a compact way to write bytes. Once you can read two hex digits as one byte, memory dumps, color codes and network packets all become much easier to follow.

FAQ

Frequently asked questions

Quick answers about the hex converter and how it works.

How do I convert hex to decimal?

Multiply each digit by its place value, a power of 16, and add the results. For 1F4 that's 1 × 256 + 15 × 16 + 4 × 1 = 500. Type any hex number into the converter and the Digit by digit table shows every step.

How do I convert decimal to hex?

Type the number into the Decimal field and the hex appears as you type. By hand, divide by 16 repeatedly and read the remainders from last to first: 500 ÷ 16 = 31 remainder 4, 31 ÷ 16 = 1 remainder 15 (F), and 1 ÷ 16 = 0 remainder 1, which gives 1F4.

Is FF equal to 255 or −1?

Both, depending on how the bits are read. As an unsigned number FF is 255. As a signed 8-bit number it's −1, because two's complement treats the top bit as negative. In 16 bits, 00FF is 255 either way. The Signed and unsigned table shows all four common widths.

How do I convert hex to text?

Switch to Text and paste the hex into the Hex box. Each pair of digits is one byte, and the bytes are decoded as UTF-8, so 48 65 6C 6C 6F reads Hello. Spaces, commas, colons, 0x prefixes and \x escapes are all accepted.

How do I convert text to hex?

Switch to Text and type into the Text box. Every character becomes its UTF-8 bytes, two hex digits each: Hi is 48 69, and the emoji 👋 takes four bytes, F0 9F 91 8B. The menu switches the output to formats like 0x48, 0x69 or \x48\x69.

What do big-endian and little-endian mean?

They're the two ways to store a multi-byte number in memory. Big-endian puts the most significant byte first, so the 32-bit value DEADBEEF is stored as DE AD BE EF. Little-endian, used by x86 and most ARM systems, stores it as EF BE AD DE.

Can I enter negative hex numbers?

Yes. Type a minus sign, like -2A for −42. The fields keep the sign, and the tables show the two's complement patterns a computer would store: D6 in 8 bits and FFFF FFFF FFFF FFD6 in 64 bits.

Still have a question?Contact us