Number converter · Free · No sign-up
Decimal to Hex Converter
To convert decimal to hex, divide by 16 repeatedly, write each remainder as a hex digit (10 to 15 are A to F) and read them from last to first. 48879 gives F, E, E, B, so it is BEEF, and 255 is FF. A negative number becomes a two's complement pattern: -1 is FFFFFFFF in 32 bits.
Every division by 16 shown.
- Divide 48879 by 16 again and again, writing down each remainder.
- 48879 ÷ 16 = 3054 remainder 15 (F)
- 3054 ÷ 16 = 190 remainder 14 (E)
- 190 ÷ 16 = 11 remainder 14 (E)
- 11 ÷ 16 = 0 remainder 11 (B)
- Read the remainders from the last to the first: BEEF.
| Form | Value |
|---|---|
| Binary (base 2) | 1011111011101111 |
| Octal (base 8) | 137357 |
| Decimal (base 10) | 48879 |
| Hexadecimal (base 16) | BEEF |
| Binary in groups of four | 1011 1110 1110 1111 |
The figures above are an example: put in your own decimal number. Spaces and underscores between digit groups are ignored, and 0b, 0o, 0x or # in front are read when they match the base. Worked out exactly in this browser and kept there; nothing is sent anywhere. Going the other way? Use hex to decimal.
Type a decimal number and read it in hex, with each division by 16 and its remainder listed. Binary and octal are in the table too, and a bit width turns negative numbers into their hex pattern.
Decimal to hex conversion rewrites a base-10 number in base 16, whose digits run 0 to 9 and then A (10) to F (15), so that each hex digit stands for exactly four bits.
- No sign-up
- Nothing uploaded
- Shows every step
- Works offline
- Exact, any size
Key facts
| Detail | Answer |
|---|---|
| Method shown | Divide by 16, write each remainder as 0 to 9 or A to F, read upwards |
| Example | 48879 = BEEF; 255 = FF; 1000 = 3E8 |
| Fractions | Multiply by 16 and keep the whole parts; repeats in brackets |
| Negative numbers | Two's complement at 8, 16, 32 or 64 bits: −1 = FFFFFFFF at 32 bits |
| Size | Up to 256 characters, exact |
| Where your numbers are kept | This browser only |
How to convert decimal to hex by hand
Repeated division by 16, as the converter lists it.
Divide the number by 16
Write down the whole-number answer and the remainder, 0 to 15.
Write the remainder as a hex digit
10 is A, 11 B, 12 C, 13 D, 14 E, 15 F.
Divide the answer by 16 again
Repeat until the answer is 0.
Read the remainders upwards
The last remainder is the leftmost hex digit.
For a colour, do each channel alone
And pad each to two digits: 5 is 05.
Check with the converter
Its working lists the same divisions.
Who converts decimal to hex
Anyone turning an ordinary number into the form computers and standards print.
Web designers
RGB colour channels into a #RRGGBB code.
Programmers
Constants, masks and byte values for code.
Students
Base-16 homework with every division shown.
Unicode and HTML writers
Character numbers into U+ code points and &#x references.
Reverse engineers
Offsets and sizes in the form a hex editor shows.
Electronics hobbyists
Register values for datasheets written in hex.
Decimal RGB to a hex colour code
The most common reason to turn decimal into hex is a colour. CSS and design tools give colours as three channels from 0 to 255, such as rgb(255, 87, 51), and the hex code is just those three numbers in base 16, two digits each, one after the other. The W3C CSS Color Module Level 4 defines it that way: the first pair is red, the second green, the third blue, each from 00 to ff (255), and an optional fourth pair is the alpha.
| RGB in decimal | Each channel in hex | Hex code |
|---|---|---|
| 255, 87, 51 | FF, 57, 33 | #FF5733 |
| 0, 128, 128 | 00, 80, 80 | #008080 |
| 5, 10, 200 | 05, 0A, C8 | #050AC8 |
| 255, 255, 255 | FF, FF, FF | #FFFFFF |
| 17, 34, 51 | 11, 22, 33 | #112233, shortened to #123 |
The step that trips people up is padding. Convert each channel on its own and always write two digits: 5 is 05, not 5, and 10 is 0A. Without the zero, rgb(5, 10, 200) would come out as #5AC8, which is a different four-digit code. Converting the three channels as one big number does not work either. The short three-digit form only exists when each pair is a doubled digit, as in #112233 = #123. To choose a colour and see its hex, RGB and HSL together, use the colour picker. To read a hex code back, use the hex to decimal colour reader.
How many hex digits a value needs
One hex digit is four bits, so the number of hex digits tells you the storage size directly. This is the main reason hex is used for memory and file sizes.
| Largest value | Hex | Bits | Size |
|---|---|---|---|
| 15 | F | 4 | One nibble |
| 255 | FF | 8 | One byte |
| 65,535 | FFFF | 16 | Two bytes |
| 16,777,215 | FFFFFF | 24 | A 24-bit colour |
| 4,294,967,295 | FFFFFFFF | 32 | Four bytes |
| 18,446,744,073,709,551,615 | FFFFFFFFFFFFFFFF | 64 | Eight bytes |
Powers of 1024 also look round in hex: 1,024 is 400, 65,536 is 10000 and 1,048,576 is 100000. NIST’s page on binary prefixes gives those as one kibibyte (210 bytes) and one mebibyte (220 bytes), names the IEC approved in December 1998 to tell them apart from the decimal kilobyte and megabyte.
Negative decimals in hex
A negative decimal number in hex is the two’s complement bit pattern written four bits a digit. Pick the width in the converter: the same −1 is FF in a byte and FFFFFFFF in 32 bits, which is why you need to know the width before you can read a hex value as negative.
| Decimal | 8-bit | 16-bit | 32-bit |
|---|---|---|---|
| −1 | FF | FFFF | FFFFFFFF |
| −2 | FE | FFFE | FFFFFFFE |
| −16 | F0 | FFF0 | FFFFFFF0 |
| −128 | 80 | FF80 | FFFFFF80 |
| −256 | Does not fit | FF00 | FFFFFF00 |
A shortcut for checking: the pattern plus the size of the number is the width’s power of 2. FF (255) + 1 = 256, so FF is −1 at 8 bits; FF80 (65,408) + 128 = 65,536, so FF80 is −128 at 16 bits.
Where decimal numbers are written in hex
Decimal-to-hex conversion comes up wherever a standard writes numbers in hex but people think in decimal.
| Use | Decimal | Hex | Written as |
|---|---|---|---|
| A Unicode character | 233 | E9 | U+00E9 (é), or é in HTML |
| An HTML character reference | 169 | A9 | © or © (©) |
| A network port in a packet dump | 443 | 1BB | 01 BB |
| A byte value | 200 | C8 | 0xC8 |
| A colour channel | 87 | 57 | The middle pair of #FF5733 |
Unicode code points are always given in hex with at least four digits, so 233 becomes U+00E9; HTML accepts either form, decimal with &# or hex with &#x.
What this page does not do
This page converts numbers. It does not encode text as hex bytes (a string to its UTF-8 bytes), and it does not show how a float is laid out in memory. Up to 256 characters, worked exactly; decimal fractions are converted too, with repeating hex digits in brackets: 0.1 is 0.1(9).
The hex code of a letter or symbol, such as 41 for A, comes from the ASCII to hex converter, which handles whole strings.
| It does | It does not |
|---|---|
| Whole numbers of any size and decimal fractions | Turn text into hex bytes |
| Negatives at 8, 16, 32 or 64 bits | Show float or double layouts |
| Every division by 16, with A to F named | Send your numbers anywhere |
This converter or a typical one
| This page | A typical one | |
|---|---|---|
| Every division by 16 shown | Yes, with A to F named | Often the answer only |
| Decimal fractions | Exact, repeats marked | Usually refused |
| Negative numbers | Two's complement at your width | A fixed width or none |
| Numbers past 253 | Exact | Often rounded |
| Your numbers leave the browser | Never | Varies |
More converters
Every converter on the site runs in your browser, needs no sign-up, and sends nothing anywhere.
Numbers & code6
Binary, hex, octal and any base, number systems, and codes generated in the browser.
Hex to decimal
Powers of 16 shown, #RGB to #RRGGBBAA colour codes read as channels, signed bytes and 0x addresses.
Open hex to decimal →Password generator
Random characters or EFF-word passphrases from the browser's crypto, no modulo bias, exact entropy, nothing sent.
Open password generator →ASCII, hex, binary, decimal converter
Text and byte codes both ways in one box, UTF-8 beyond 127 shown byte by byte, control characters named, Base64.
Open ascii, hex, binary, decimal converter →Binary converter
Binary, octal, decimal, hex or any base 2 to 36, exact at any size, fractions and two's complement, with steps.
Open binary converter →Binary to decimal
Each bit times its power of 2, binary fractions after the point, and signed patterns read at 8 to 64 bits.
Open binary to decimal →Decimal to binary
Repeated division by 2 shown step by step, 0.1 as the repeating 0.0(0011), negatives in two's complement.
Open decimal to binary →
All 34 converters, by category: Length (10) · Weight & mass (5) · Temperature (3) · Cooking (1) · Currency (1) · Numbers & code (7) · Text (2) · Images (3) · Dates & time (2)
Frequently asked questions
How do you convert decimal to hexadecimal?
Divide by 16 and write down the remainder as a hex digit; divide the answer by 16 again until it reaches 0, then read the remainders from last to first. 300 divided by 16 is 18 remainder 12 (C), then 1 remainder 2, then 0 remainder 1, so 300 is 12C.
What is 255 in hex?
255 is FF: 15 sixteens and 15 ones, the largest two-digit hex number and the largest value of one byte. That is why a colour channel at full strength is FF and why #FFFFFF is white. One more, 256, needs three hex digits: 100.
What is 1000 in hex?
1000 is 3E8 in hex. 1000 divided by 16 is 62 remainder 8; 62 divided by 16 is 3 remainder 14, which is E; and 3 divided by 16 is 0 remainder 3. Read upwards: 3E8. Check: 3 x 256 + 14 x 16 + 8 = 1000.
How do I convert an RGB colour to hex?
Convert each of the three channels on its own and write each as two hex digits, padding with a zero when needed, then put them together after a #. rgb(255, 87, 51) is FF, 57, 33, so #FF5733. Converting the channels as one number gives a wrong code.
Why does hex use the letters A to F?
Base 16 needs sixteen digits and our numerals only go to 9, so the letters A to F stand for 10 to 15. Case does not matter: ff and FF are the same number. The converter prints capitals and reads either.
How do I write a negative number in hex?
In code, negative values are stored as two's complement, so -1 is FF in 8 bits, FFFF in 16 bits and FFFFFFFF in 32. Choose the width in the converter and it shows the pattern and the steps. Written by hand, you can also use a minus sign: -FF is -255.
What is 16 in hex?
16 is 10 in hex: one sixteen and no ones. It is the first two-digit hex number, the same way 10 is in decimal. Writing 0x10 makes the base clear, since 10 alone could be read as ten. In binary, 16 is 10000.
Can decimal fractions be written in hex?
Yes: multiply the fraction by 16 and take the whole part as the next hex digit, repeatedly. 0.5 is 0.8 and 0.75 is 0.C. Most decimal fractions repeat: 0.1 is 0.1999..., written 0.1(9) here, because 10 has a factor of 5 that no power of 16 has.
Related guides
Longer answers to the questions behind the numbers.
- Reference
Types of counters explained
Synchronous vs asynchronous, mod-N, ring and Johnson, industrial and PLC counters, plus mechanical and software counters.
- Tallying
Tally marks explained
Groups of five, the five-bar gate, and why the convention has survived for centuries.
- Counting
Count to 1,023 on your fingers
The value of each of ten fingers, worked examples, how to count up, and why the top is 1,023.
- Tallying
Tally marks in Excel and Google Sheets
The REPT, INT and MOD formula for five-bar gates, tested on every count from 0 to 120; a tally chart from raw answers with COUNTIF; and why LEN miscounts typed tallies.
- Counting
Why word counts differ between tools
The same sentence is 26 words to one counter and 39 to another. Four counting rules side by side, and how to meet a hard limit whichever one a form uses.