Xerobit

Decimal to Hex Converter

Enter a base-10 integer to get its hexadecimal representation. This decimal to hex converter handles arbitrarily large numbers using BigInt, lets you toggle the 0x prefix, choose upper or lower case, and group digits for readability. It runs entirely in your browser so nothing is uploaded.

Result

  • Hexadecimal
    0xFF

How to use the decimal to hex

  1. Enter an integer in the Decimal number field. You can type very large values without losing precision.
  2. Toggle Add 0x prefix if you need the standard programming notation.
  3. Choose Uppercase or Lowercase for the A through F digits.
  4. Select a Group digits by option to insert separators every 2, 4, or 8 characters.
  5. The hexadecimal result updates live as you change any setting.

How decimal to hex conversion works

Hexadecimal is base 16, meaning each position represents a power of 16 instead of a power of 10. The digits are 0 through 9 followed by A through F (representing 10 through 15). To convert a decimal integer to hex, repeatedly divide the number by 16 and record the remainders.

Take the decimal number 255 as an example. Divide 255 by 16 to get a quotient of 15 and a remainder of 15. In hex, 15 is written as F. Then divide the quotient 15 by 16 to get 0 with a remainder of 15, which is again F. Reading the remainders from last to first gives FF. So 255 in base 10 equals FF in base 16.

This tool uses JavaScript BigInt internally, so it can handle integers with hundreds of digits without rounding errors. Python users can verify results with hex(255) which returns '0xff', or int('FF', 16) which returns 255.

Common decimal to hex reference values

The table below lists frequently used conversions. These values appear often in programming, networking, and color specifications.

DecimalHexadecimalNotes
00Zero in any base
10AFirst letter digit
15FMaximum single hex digit
1610One full base-16 place
1277FMaximum signed 8-bit integer
255FFMaximum unsigned byte
256100Two full bytes
1024400One kibibyte
40961000Common memory page size
65535FFFFMaximum unsigned 16-bit integer
1048576100000One mebibyte

Why use the 0x prefix and digit grouping

In C, C++, JavaScript, Python, and many other languages, the 0x prefix tells the compiler or interpreter that the following digits are hexadecimal rather than decimal. Without it, 10 means ten, but 0x10 means sixteen. Enabling the prefix in this decimal to hex converter produces output you can paste directly into source code.

Digit grouping improves readability for long values. Grouping by pairs (every 2 hex digits) aligns with bytes, since two hex digits represent exactly 8 bits. Grouping by 4 aligns with 16-bit words, and grouping by 8 aligns with 32-bit double words. For example, the ungrouped hex string AB54A98CEB1F0AD2 becomes AB:54:A9:8C:EB:1F:0A:D2 when grouped by bytes, making it much easier to read at a glance.

Relationship between hex, binary, and other bases

Hexadecimal is popular in computing because each hex digit maps perfectly to four binary digits (bits). This makes converting between hex and binary straightforward: you simply replace each hex character with its 4-bit binary equivalent. If you need to go further, tools like hex to binary or decimal to binary handle those conversions directly.

To reverse the process and convert a hex string back to base 10, use the hex to decimal tool. For octal conversions, see decimal to octal. When working with raw file data or memory dumps, the hex dump utility formats binary content into readable hex rows.

Handling negative numbers and large integers

This converter outputs negative numbers with a minus sign followed by the hex magnitude, such as -0x1000 for decimal -4096. This matches mathematical convention and the behavior of Python's hex() function. It does not produce two's complement representations automatically, because two's complement depends on a fixed bit width (8-bit, 16-bit, 32-bit, etc.). If you need two's complement output, use the dedicated two's complement calculator.

Because the tool relies on BigInt arithmetic, there is no practical upper limit to the input size. Standard floating-point numbers lose integer precision beyond 253 (about 9 quadrillion), but BigInt avoids this entirely. You can safely convert numbers with dozens or hundreds of digits.

Worked examples

ExampleInputResult
255 with prefixDecimal number: 255; Add 0x prefix: yes; Letter case: upper; Group digits by: 0Hexadecimal: 0xFF
Negative numberDecimal number: -4096; Add 0x prefix: yes; Letter case: upper; Group digits by: 0Hexadecimal: -0x1000
Large value grouped by bytesDecimal number: 12345678901234567890; Add 0x prefix: no; Letter case: lower; Group digits by: 2Hexadecimal: ab:54:a9:8c:eb:1f:0a:d2
ZeroDecimal number: 0; Add 0x prefix: no; Letter case: upper; Group digits by: 0Hexadecimal: 0

FAQ

How do I convert decimal to hex manually?

Divide the decimal number by 16. Write down the remainder as a hex digit (0-9 or A-F). Use the quotient for the next division. Repeat until the quotient is zero, then read the remainders in reverse order.

What does the 0x prefix mean?

The 0x prefix is a convention in many programming languages indicating that the digits following it are in base 16. For example, 0xFF means 255 in decimal.

Can this tool handle very large numbers?

Yes. The converter uses BigInt arithmetic, so it supports integers of any size without losing precision, far beyond the limits of standard floating-point math.

Why would I group hex digits by 2 or 4?

Two hex digits equal one byte (8 bits), and four hex digits equal one 16-bit word. Grouping makes long hex strings easier to read and aligns with how memory and network protocols organize data.

Does this converter support negative numbers?

Yes. Negative inputs produce a minus sign before the hex value, such as -0x1A. This matches standard mathematical notation and Python's hex() function.

Is my data sent to a server?

No. All conversion happens locally in your browser using JavaScript. Nothing you type is transmitted anywhere.

How do I verify the result in Python?

Use the built-in hex() function. For example, hex(255) returns '0xff'. To convert back, use int('FF', 16) which returns 255.