Decimal to Hex Converter
Convert a base-10 decimal number to base-16 hexadecimal. Enter a whole number to get the exact hex result, plus binary and octal equivalents.
What is Decimal to Hex Conversion?
Decimal to hexadecimal conversion changes a base-10 number (digits 0-9) into its base-16 equivalent, which uses digits 0-9 plus letters A-F to represent values 10 through 15. Converting decimal to hex is the basis for reading memory addresses, color codes, and byte values in a compact form.
For example, decimal 255 is the largest value a single byte can hold, and it equals hexadecimal FF. To convert the other direction, use the Hex to Decimal Converter. For the related base-2 conversion, see Decimal to Binary.
How to Convert Decimal to Hex Manually
The standard manual method is repeated division by 16:
Division-by-16 method
- Step 1: Divide the decimal number by 16.
- Step 2: Record the remainder, converting it to a hex digit if it's 10 or higher (A=10, B=11, C=12, D=13, E=14, F=15).
- Step 3: Divide the quotient by 16 again.
- Step 4: Repeat until the quotient reaches 0.
- Step 5: Read the remainders in reverse order (bottom to top) — that is the hexadecimal result.
Worked example: convert 255 to hexadecimal
255 ÷ 16 = 15 remainder 15 (F) 15 ÷ 16 = 0 remainder 15 (F) Reading remainders from bottom to top: FF Therefore, 255 in decimal = FF in hexadecimal
Manual division is useful for understanding the mechanics, but it is easy to drop a remainder on longer numbers — the converter above returns the exact result for any size of input. For a fuller walkthrough with more worked examples, see How to Convert Decimal to Hex.
Hex Digit Reference (0-9, A-F)
Hexadecimal is base 16, so each digit position can hold 16 possible values. Decimal 0-9 use the same digits in hex; decimal 10-15 use the letters A-F.
| Decimal | Hex |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
| 5 | 5 |
| 6 | 6 |
| 7 | 7 |
| 8 | 8 |
| 9 | 9 |
| 10 | A |
| 11 | B |
| 12 | C |
| 13 | D |
| 14 | E |
| 15 | F |
Decimal to Hex Conversion Table
A quick reference for common decimal numbers and their hexadecimal equivalent:
| Decimal | Hexadecimal |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 9 | 9 |
| 10 | A |
| 15 | F |
| 16 | 10 |
| 26 | 1A |
| 31 | 1F |
| 32 | 20 |
| 42 | 2A |
| 100 | 64 |
| 255 | FF |
| 256 | 100 |
| 4095 | FFF |
Where Decimal to Hex Conversion Is Used
- Programming and debugging: memory dumps, pointers, and error codes are typically printed in hex because it maps cleanly onto bytes (2 hex digits = 1 byte).
- Memory addresses: operating systems and debuggers display addresses in hexadecimal for compact, unambiguous reading.
- Color and data representation: CSS/HTML color codes (such as #FF5733) are three hex byte pairs for red, green, and blue.
- Low-level systems: MAC addresses, hash digests, and binary file dumps are conventionally shown in hex rather than binary or decimal.
- Computer science education: converting between decimal, binary, and hex builds the base-conversion skills used throughout systems courses. The Decimal to Binary Converter covers the related base-2 case.
Negative Numbers and Two's Complement
This converter accepts zero and positive integers only. Simply writing a minus sign in front of a hex string (for example, -FF) isn't how computers represent negative numbers, and it isn't a fixed, unambiguous format on its own.
Machines represent negative numbers using two's complement, which requires choosing a fixed bit width (such as 8, 16, or 32 bits) before the hex representation makes sense. Use the Two's Complement Calculator to convert a negative decimal value into its signed representation at a specific bit width.
Related Converters
Hex to Decimal
Convert hexadecimal numbers back to decimal — the reverse of this tool.
Decimal to Binary
Convert decimal numbers to binary notation.
Binary to Hex
Convert binary numbers to hexadecimal notation.
Hex to Binary
Convert hexadecimal numbers to binary notation.
Two's Complement Calculator
Represent negative numbers in binary or hex at a fixed bit width.
Binary Calculator
Add, subtract, multiply, and divide binary numbers.
Frequently Asked Questions
How do I convert 255 to hex?
255 in decimal equals FF in hexadecimal. Dividing 255 by 16 repeatedly and reading the remainders bottom to top gives F then F.
What is the hex equivalent of 0?
0 in decimal is 0 in hexadecimal — it is the same value in every base.
Can I convert negative numbers to hex?
Not directly here. Negative numbers need a fixed bit width and a signed format such as two's complement — use the Two's Complement Calculator for that.
Why is hex used instead of decimal for things like colors and memory?
Hex aligns exactly with bytes: two hex digits represent one 8-bit byte (0-255), so values are more compact than decimal and far more compact than binary.
What is the largest decimal number this tool can convert?
There is no fixed size limit. Conversion uses BigInt arithmetic, so arbitrarily large integers convert exactly rather than losing precision — unlike JavaScript's native Number type, which becomes inexact beyond 2^53 - 1 (9,007,199,254,740,991).
Can I convert a decimal fraction like 10.5?
No — this converter handles whole numbers only. Enter the integer part; hexadecimal fractions use a different representation than integer conversion produces.
Is hexadecimal case-sensitive?
No. FF, ff, and Ff all represent the same value, 255 in decimal. This converter outputs uppercase letters for consistency.
Related Tools
You might also find these tools useful
Base Converter
Convert whole numbers between binary, octal, decimal, hex, and custom bases 2-36 in one hub.
Binary Converter
Convert text, UTF-8 bytes, and binary values without focusing only on readable messages.
Binary Calculator
Add, subtract, multiply, and divide binary numbers for math and computer science exercises.
Binary to Decimal
Turn base-2 numbers into decimal values for programming, networking, and study notes.
Binary to HEX
Compress long binary strings into hexadecimal groups for code, memory, and color checks.
Decimal to Binary
Convert everyday base-10 numbers into binary with clear fixed-width output.