Decimal to Hex Converter

Convert decimal numbers to hexadecimal exactly, with step-by-step working.

Decimal to Hex Converter tool

Whole numbers of any length, positive or negative. Commas are ignored.

—
Hexadecimal
—
Binary
—
Octal
—
Digits in the result

About the Decimal to Hex Converter

Programmers convert decimal values to hexadecimal for color codes, memory sizes, bit masks and protocol fields. This decimal to hex converter handles whole numbers of any size exactly and shows the repeated division by 16 with each remainder: 2026 becomes 7EA and 255 becomes FF. Binary and octal equivalents are shown too, which makes it useful for checking homework and debugging low-level code.

The converter uses the repeated-division method you would use on paper: divide by 16, keep the remainder, divide the quotient again, and read the remainders backwards. Every division is listed in the working section so you can follow or check it. Examples: 255 in decimal is FF in hexadecimal; 4096 in decimal is 1000 in hexadecimal; 65535 in decimal is FFFF in hexadecimal.

Converting decimal to hex comes up when writing color codes, setting register values, encoding characters (Unicode code points are written in hex), or reading values from documentation that expects hexadecimal. Because 16 is a power of 2, hex lines up perfectly with bytes: two hex digits always make one byte, so 255 becomes FF and 65,535 becomes FFFF.

Other bases are covered by the number base converter, which converts between any bases from 2 to 36. For arithmetic in these bases, use the binary calculator or the hex calculator; to turn text into its binary character codes, use text to binary.

How to use the Decimal to Hex Converter

  1. Enter the decimal numberType or paste the number. Whole numbers of any length, positive or negative. Commas are ignored.
  2. Read the hexadecimal resultThe hexadecimal value appears instantly, along with the binary and octal equivalents.
  3. Follow the workingOpen the step-by-step section to see how the conversion was done, digit by digit or division by division.
  4. Copy or shareCopy all results with one click, or copy a link that reopens the converter with the same number.

Decimal to Hex Converter features

  • Exact conversion of numbers of any length using BigInt arithmetic
  • Step-by-step working for homework and exam practice
  • Binary and Octal results shown alongside
  • Negative numbers with 8- to 128-bit two's complement forms
  • Optional digit grouping (4 bits, 2 hex digits or thousands) for easy reading
  • Accepts prefixes such as 0x, 0b and 0o and ignores spaces and underscores
  • Runs in your browser with nothing sent to a server

Common uses

  • Checking computer science and digital electronics homework
  • Reading values from datasheets, debuggers and log files
  • Working out color codes, permissions and bit masks
  • Converting values for programming and scripting
  • Learning how positional number systems work

Decimal to hex in practice: turning RGB values into colour codes, Unicode code points, padding, compact IDs and spreadsheets

By the FreeToolsWorld editorial team · Updated November 2026 · How we write and check our guides

Decimal-to-hex conversion is what turns a designer's RGB numbers into a colour code, a character's decimal number into a Unicode reference and a long order number into a shorter code. This guide converts a brand colour, works through a Unicode letter by hand, and covers padding to fixed widths, shorter identifiers, negative values in programs and converting whole columns in a spreadsheet.

A worked example: a brand colour

A designer specifies a brand green as red 21, green 128 and blue 61. Converting each value to two hex digits gives 15, 80 and 3D, so the colour code is #15803D. Each channel must be written with exactly two digits, so a value such as 5 becomes 05, otherwise the code shifts and produces a completely different colour.

A Unicode letter by hand

The Urdu letter ی, the form of yeh used in Urdu, has the decimal code point 1740. Dividing by 16 gives 108 remainder 12, then 6 remainder 12, then 0 remainder 6. Reading the remainders backwards, with 12 written as C, gives 6CC, so the letter is U+06CC. Unicode references are written with at least four digits, so leading zeros are added.

Padding to fixed widths

Many formats expect a fixed number of hex digits: two per byte, four for most Unicode references, eight for 32-bit values. The converter gives the shortest form, so add leading zeros to reach the required width. Spreadsheet functions such as DEC2HEX accept a second argument specifying the number of places to pad automatically.

Shorter identifiers

Hexadecimal writes large numbers in fewer characters: one million becomes F4240, five characters instead of seven. Some systems use hex for reference codes and short identifiers for this reason. Bases with more symbols, such as base 36, shorten them further, at the cost of mixing more letters into the code.

Negative values in programs

Computers usually store negative integers in two's complement form, so −1 stored in a byte appears in hex as FF, and in 32 bits as FFFFFFFF. When a hex dump or debugger shows values close to the maximum for their width, they may really be small negative numbers. Documentation for the data format confirms whether values are signed.

Hex in code and markup

Programming languages mark hex values with 0x, as in 0xFF, while CSS uses a hash before colour codes and Unicode uses U+. HTML accepts hex character references written as ی. Knowing which prefix each context expects avoids errors when copying values between code, styles and documents.

Exam working

For coursework, set out each division with its quotient and remainder, convert remainders of 10 to 15 into the letters A to F, and read the remainders from the bottom up. Converting the answer back to decimal with place values is a quick way to confirm it before moving on.

Converting columns of values

When a spreadsheet holds many decimal values, such as RGB components for a palette or character codes, DEC2HEX converts the whole column at once. Combining three padded results with text joining produces full colour codes for every row, ready to paste into a stylesheet or design tool.

Checking colour conversions

After converting a colour, paste the code into a colour picker and compare it with the original swatch. A mismatch usually means a channel was written with one digit instead of two, or two channels were swapped. Checking takes seconds and prevents the wrong shade appearing across a whole site.

Common mistakes

  • Writing single-digit colour channels without a leading zero.
  • Reading division remainders in the wrong order.
  • Forgetting to pad Unicode references to four digits.
  • Misreading two's complement negatives as large positive numbers.

Related tools

To convert back, use Hex to Decimal Converter. For colours specifically, try RGB to HEX Converter, and to look up characters by code point, Unicode Converter.

Splitting a number into bytes

Protocols and file formats often store numbers as a fixed number of bytes. The value 1000 is 3E8 in hex, padded to 03E8 for two bytes. Stored with the most significant byte first, the bytes are 03 then E8; stored little-endian, as many processors do, they appear as E8 then 03. Converting to hex first makes this split easy to see.

Ports and protocol values

Network captures and low-level logs often show numbers in hex. The HTTPS port 443, for example, appears as 01BB. Converting familiar decimal values into hex before searching a capture helps you find the packets or fields you are looking for.

Powers of sixteen

Memorising 16, 256, 4,096 and 65,536, the first powers of sixteen, makes estimating hex lengths easy. Any number below 256 fits in two hex digits, below 65,536 in four. This also explains why many limits in computing, such as 65,535 ports, sit just below a power of sixteen.

Privacy

Conversions run in your browser. Nothing you enter is sent anywhere or stored.

Frequently asked questions

How do I convert decimal to hex by hand?

Divide the number by 16 and note the remainder, writing 10 to 15 as A to F. Repeat with the quotient until it reaches 0, then read the remainders from last to first. For 500: remainders 4, 15 (F) and 1 give 1F4.

What is the largest number this converter can handle?

It accepts up to 400 digits, far beyond the 64-bit limit of 18446744073709551615 (2^64 − 1). The calculation uses arbitrary-precision integers, so even very long numbers convert exactly without rounding.

Can I convert negative numbers?

Yes. Put a minus sign in front and the result keeps the sign, for example -255 in decimal is -FF in hexadecimal. For binary work, the details section also shows the two's complement form that computers use to store negative integers.

Does it convert fractions or decimal points?

No. The converter works with whole numbers, which is what bases are used for in computing. Fractional values such as 0.1 often have infinitely repeating forms in binary, so they need a separate floating-point tool.

Why are the digits grouped?

Grouping makes long numbers easier to read and check: binary is split into blocks of 4 bits (one hex digit each), hex into pairs (one byte each) and decimal into thousands. Untick the grouping option to get one continuous string for copying into code.

Are hex letters case-sensitive?

No. The letters A to F and a to f mean the same values, 10 to 15, so 1f4, 1F4 and 0x1F4 are all read as 500. The converter accepts either case and always shows hex results in capitals, which is the most common convention in documentation.