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
#FF8000are three bytes: 255 red, 128 green and 0 blue. - Escapes. Strings use
\x41for a single byte, and URLs use percent signs, as in%20for a space. - Code points. Unicode writes characters in hex, so
U+0041is 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.