Convert Decimal to Hex
Convert decimal numbers to hexadecimal instantly, individually or in bulk. Free, client-side converter with copy and download built in.
- Runs in your browser
- Nothing uploaded
- Free, no sign-up
Encode decimal integers as hexadecimal with full control over representation (two's complement for negatives), bit width (8/16/32/64), case, grouping, and prefix (0x, #, or none). BigInt under the hood for arbitrary-size input.
How to Use Convert Decimal to Hex
- Enter decimals, one per line. Positive, negative, and arbitrarily large - BigInt handles everything above 253 exactly.
- Pick representation. Two's complement (default) is what CPUs use:
-5in 8-bit hex isfb. Sign-magnitude keeps the minus sign:-5. Unsigned refuses negatives entirely. - Pick bit width. Auto uses the minimum nibble-aligned width. 8/16/32/64 pad shorter values and reject overflows with a specific error.
- Choose case (lower or upper) and optional grouping (byte pairs or 4-digit halfwords separated by spaces).
- Choose prefix -
0xfor C/Python/JS,#for CSS color literals, or none for raw hex. - Enable the breakdown to see per-value details. Press Convert (or Ctrl+Enter); live preview runs 150 ms after typing. Invalid lines are flagged per-line.
Frequently Asked Questions
What is hexadecimal?
A base-16 number system using the 16 digits 0-9 and a-f (or A-F). Each hex digit encodes exactly 4 bits, so two hex digits = one byte. That’s why hex is the standard for byte-level representation in debuggers, memory dumps, colour codes, and cryptographic hashes.
Why is 255 equal to ff?
Because 255 in base 10 fills all 8 bits of one byte, and the largest 2-digit hex value is ff = 15 × 16 + 15 = 255. So 255 is the maximum unsigned byte and ff is its hex form – one of the reasons hex is so useful for byte-level work.
How are negative numbers encoded?
Default is two’s complement, matching how CPUs store signed integers. In 8-bit two’s complement, -5 is fb (because 256 − 5 = 251 = fb). Sign-magnitude mode instead prints -5 with a literal minus sign – useful for human-readable output but not for machine representation.
Why does auto-width produce an even number of hex digits?
Because the tool rounds up to the next multiple of 4 bits (one hex nibble). Decimal 200 needs 8 bits of binary, so 2 hex digits (c8). Decimal 1000 needs 10 bits of binary, rounded up to 12 bits, so 3 hex digits (3e8). This keeps the output nibble-aligned.
What’s the difference between 0x, 0X, and # prefixes?
0x is the C convention adopted by almost every modern language (Python, JavaScript, Rust, Java 7+, C23). 0X is the same but uppercase – allowed in C but less common. # is the CSS colour prefix (#ff0000) and was used historically in some assemblers. Pick based on where you’ll paste the result.
What happens with overflow?
You get a specific error naming the limit: “overflow: 256 exceeds unsigned 8-bit max ff (255)” or “overflow: 128 exceeds signed 8-bit range [-128, 127]”. The tool refuses to silently truncate – overflows usually indicate a real bug in the caller’s math.
How large a number can I convert?
No practical upper bound. The tool uses BigInt, so 2128, 21000, or a 200-digit decimal all convert exactly. JavaScript’s Number.toString(16) would quietly round past 253 ≈ 16 decimal digits, but BigInt avoids that.
Can I convert decimal fractions like 0.5?
No – integer only. 0.5 in hex floating-point notation would be 0x1p-1 (IEEE 754-style), which is a different encoding. Use a float-to-hex tool for fractional values.
What’s a CSS colour use case?
Enter 16711680 (the RGB decimal for pure red), pick 24-bit width and # prefix, and you get #ff0000. For alpha: pick 32-bit width. This tool isn’t a CSS colour picker but makes the math painless when you have a raw RGB integer.
Is the tool free, offline, and private?
Yes. All arithmetic runs in your browser via JavaScript + BigInt. No upload, no tracking, no account. Load the page once and it works offline indefinitely.
Related Tools
Convert Hex to Decimal →
Convert hex to decimal with BigInt precision. Explicit bit-width two's complement for signed values,…
Add Hex Numbers →
Add Hex Numbers instantly. Free, offline, client-side tool that outputs results in both hex…
ASCII to Hex Converter →
Convert ASCII to Hex - code points or UTF-8 bytes, space/comma/0x-prefixed, uppercase or lowercase.…
Base32 to Hex Converter →
Base32 to Hex Converter - pick separator, case, and prefix. Free, client-side, instant, offline,…
Base58 to Hex Converter →
Decode Bitcoin, Ripple, or Flickr Base58 strings to hex - with separator, case, and…
Base64 to Hex Decoder →
Decode Base64 to hex bytes - URL-safe variant, separator options, uppercase toggle, UTF-8 aware.…
BCD to Hex Converter →
Convert packed BCD to hexadecimal - decimal-value or nibble mode, BigInt precision, COMP-3 sign.…
Convert Gray Code to Hex →
Decode Gray code (reflected binary) to hex, decimal, or binary. Accepts binary or hex-packed…
Convert Hex to ASCII →
Decode hexadecimal bytes to ASCII text. Auto-detect separators, handle non-printable bytes four ways, batch…
Convert Hex to BCD →
Convert hex to Binary Coded Decimal - packed, unpacked, or COMP-3 with sign nibble.…
Convert Hex to Binary →
Convert hex to binary with nibble-accurate bit widths. 5 grouping modes, 0b prefix toggle,…
Convert Hex to Gray Code →
Convert hex to Gray code (reflected binary) with BigInt precision. Handles 32+ bit values…