Home Tools Blog About

Convert Decimal to Hex

In short

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.

🛡
100% PrivateNo server uploads, ever
InstantRuns in your browser
💧
No WatermarksClean output, always
🆓
Free ForeverNo accounts, no limits

How to Use Convert Decimal to Hex

  1. Enter decimals, one per line. Positive, negative, and arbitrarily large - BigInt handles everything above 253 exactly.
  2. Pick representation. Two's complement (default) is what CPUs use: -5 in 8-bit hex is fb. Sign-magnitude keeps the minus sign: -5. Unsigned refuses negatives entirely.
  3. Pick bit width. Auto uses the minimum nibble-aligned width. 8/16/32/64 pad shorter values and reject overflows with a specific error.
  4. Choose case (lower or upper) and optional grouping (byte pairs or 4-digit halfwords separated by spaces).
  5. Choose prefix - 0x for C/Python/JS, # for CSS color literals, or none for raw hex.
  6. 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.

Keep going

Related Tools

All Hex tools →
Share

Embed this tool

Add this free tool to your website. Copy and paste the code: