Hex converter
Type a hex value and see it as decimal, binary and text at once. Then pick the tool for the job: numbers, bytes, files or colors.
Runs in your browser. Nothing you type is uploaded.
Hex numbers
For a hex value that stands for an amount, an address or a register.
Hex bytes, text and files
For hex that is a run of bytes rather than one number.
Hex colors
For six hex digits after a # sign.
What is this hex value?
The way a value is written usually tells you what it is.
| How it is written | Example | Usually means |
|---|---|---|
| 0x before the digits | 0x1A3 | A number in C, Python or JavaScript, here 419 |
| # and six digits | #FF8800 | A web color: red FF, green 88, blue 00 |
| h after the digits | 1A3h | A number in assembly language |
| $ before the digits | $FF | A number in Pascal or 6502 assembly, here 255 |
| &H before the digits | &HFF | A number in Visual Basic, here 255 |
| \x before each pair | \x48\x69 | Bytes inside a string in C, Python or a shell, here "Hi" |
| Pairs separated by spaces | 48 65 6C 6C 6F | A run of bytes, often text, here "Hello" |
Files start with the same bytes
Most file types begin with a fixed signature, sometimes called a magic number. Open a file in the hex editor and the first row shows it, whatever the file is named.
| File type | First bytes | As text |
|---|---|---|
| PNG image | 89 50 4E 47 0D 0A 1A 0A | .PNG.... |
| JPEG image | FF D8 FF | Not readable as text |
| GIF image | 47 49 46 38 | GIF8 |
| PDF document | 25 50 44 46 2D | %PDF- |
| ZIP archive, also .docx, .xlsx and .jar | 50 4B 03 04 | PK.. |
| Windows program (.exe, .dll) | 4D 5A | MZ |
| Linux program (ELF) | 7F 45 4C 46 | .ELF |
Number, bytes or a color?
Hex is base 16. The digits run from 0 to 9 and then A to F, so one hex digit covers exactly four bits and two digits cover one byte. That is why debuggers, file viewers and color codes all show bytes in hex: FF is quicker to read than 11111111.
The same digits can mean different things, so look at how the value is written. 1A3 on its own is most likely a number, 419. 48 69 with a space between pairs is usually bytes, and those read as text. Six digits after a # are a color: red, green and blue, one byte each.
Frequently asked questions
What is a hex code?
A hex code is a color written as six hex digits after a #: two for red, two for green and two for blue. Each pair runs from 00, none of that color, to FF, full strength. #FFFFFF is white, #000000 is black and #FF0000 is pure red. In programming, "hex code" can also mean any value written in hexadecimal.
How do you convert hex to decimal by hand?
Multiply each digit by 16 raised to its position, counting from 0 on the right, and add the results. A stands for 10, B for 11 and so on up to F for 15. For 1A3 that is 1 × 256 + 10 × 16 + 3 × 1 = 419.
What does 0x mean before a number?
It marks the digits as hex in C, Python, JavaScript and many other languages. Without it, 10 could be ten or sixteen. With it, 0x10 is always sixteen.