๐Ÿ”ฃ Decimal to Hex Converter

Last updated: May 4, 2026

๐Ÿ”ฃ Decimal โ†’ Hex Converter

Convert any integer to hexadecimal with prefix & nibble grouping options

Please enter a valid integer (digits only, optional leading minus).

Hexadecimal Result
Bit Width
โ€”
Nibble Count
โ€”
Binary
โ€”
Octal
โ€”
Quick Examples

Decimal to Hex Conversion: Everything You Actually Need to Know

Hexadecimal is one of those things that looks cryptic until it suddenly clicks. Once it does, you start seeing it everywhere โ€” CSS color codes, memory addresses, network MACs, file magic bytes, debug dumps, OAuth tokens, UUID segments. Behind all of it is a surprisingly simple idea: hex is just a more compact way of writing binary, and the conversion from decimal is straightforward math. Let's break it down properly.

Why Hexadecimal Exists at All

Computers think in binary โ€” ones and zeros. A single binary digit is a bit. Four bits together are called a nibble (yes, really), and eight bits make a byte. The problem is that binary is verbose. The number 255, dead simple in decimal, is 11111111 in binary โ€” eight digits for a single byte. That gets unmanageable fast when you're reading a 64-bit memory address or a 256-bit hash.

Hexadecimal (base-16) solves this elegantly. Because 16 is exactly 24, every single hex digit maps perfectly onto exactly four bits โ€” one nibble. So one byte is always exactly two hex digits. 11111111 in binary becomes FF in hex. A 32-bit value that would be 32 characters in binary is just 8 hex digits. That's the entire reason hex exists: it's human-readable shorthand for binary, with zero information loss.

The Conversion Algorithm Step by Step

The classic method uses repeated division by 16. You take your decimal number, divide it by 16, and record the remainder. Then divide the quotient by 16 again, record the remainder. Keep going until the quotient is zero. Read the remainders bottom to top โ€” that's your hex number.

Take 255 as an example. 255 รท 16 = 15 remainder 15. 15 รท 16 = 0 remainder 15. Remainders are 15 and 15. In hex, digits 10โ€“15 are represented as Aโ€“F, so 15 = F. Reading bottom to top: FF. Done. Check: F ร— 16 + F = 240 + 15 = 255. Correct.

Try 300. 300 รท 16 = 18 remainder 12. 18 รท 16 = 1 remainder 2. 1 รท 16 = 0 remainder 1. Remainders are 1, 2, 12 โ€” reading bottom to top gives 1, 2, C (since 12 = C). So 300 in hex is 12C. Verify: 1 ร— 256 + 2 ร— 16 + 12 = 256 + 32 + 12 = 300. Perfect.

What the 0x Prefix Actually Means

When you see 0xFF or 0x1A3C, the 0x is not part of the number โ€” it's a notation convention that tells the reader (and the compiler/interpreter) "this is hexadecimal." It originated in C and spread to virtually every programming language since. JavaScript, Python, Java, C++, Rust, Go โ€” all of them use 0x to denote hex literals. Some older contexts use a hash prefix instead (#FF0000 in CSS) or an h suffix (FFh in x86 assembly), but 0x is by far the most universal in modern programming.

Whether to include 0x depends on context. If you're writing a hex value into source code, include it. If you're writing a CSS color or a MAC address, omit it โ€” those formats have their own conventions. If you're documenting an API response or database field, it helps to include it to remove ambiguity.

Nibble Grouping: Making Hex Readable

Long hex strings are surprisingly hard to read at a glance. DEADBEEF is famous precisely because it's memorable โ€” but 00FF12A4C3B800E1 is not. The fix is nibble grouping: inserting a space (or sometimes a dash or colon) every four hex characters. Those four digits represent 16 bits โ€” two bytes โ€” which is a natural boundary for most data types.

So 00FF12A4C3B800E1 becomes 00FF 12A4 C3B8 00E1. Immediately easier to parse. This matters when you're comparing memory addresses in a debugger, reviewing network captures in Wireshark, or manually verifying a firmware checksum.

The tool on this page groups by four hex digits (one 16-bit word per group) with a space separator โ€” the most common convention in documentation and debugging tools.

Uppercase vs Lowercase: Does It Matter?

Mathematically, not at all. FF and ff are the same value. Stylistically, though, conventions vary. Uppercase (Aโ€“F) is traditional and still dominant in hardware documentation, hex dumps, and data sheets. Lowercase (aโ€“f) has become common in web contexts โ€” CSS colors are typically lowercase (#ff6600), and many style guides for languages like Go and Rust prefer lowercase hex. Python's hex() built-in outputs lowercase.

Pick the convention that matches your target context. If you're copying a value into CSS, lowercase. Into a C define or assembly listing, uppercase. The converter above gives you both options with a single toggle.

Negative Numbers in Hex

This is where it gets interesting. There's no universal standard for representing negative numbers in hex โ€” it depends entirely on the representation scheme. The simplest approach, used in mathematics and this converter, is just a minus sign: -255 becomes -0x00FF.

In actual hardware and low-level programming, the dominant scheme is two's complement. In 8-bit two's complement, -1 is 0xFF, -128 is 0x80, and -255 doesn't exist (8-bit signed range is -128 to 127). In 32-bit: -1 is 0xFFFFFFFF, -2147483648 is 0x80000000. If you're working with signed integers from hardware registers or low-level memory, always check the bit width and whether two's complement applies. The signed/unsigned interpretation of the same hex value can be completely different.

Real-World Places You'll Use This

CSS and design: RGB colors are three hex bytes concatenated. rgb(255, 128, 0) is #FF8000. Each channel is one byte (0โ€“255), which is always exactly two hex digits. Understanding this makes color debugging much faster.

Debugging and reverse engineering: Stack traces, core dumps, and disassemblers speak hex. When GDB tells you a segfault happened at 0x00007f8c3b2a1000, you need to be comfortable translating that to a decimal offset or size.

Networking: MAC addresses are six bytes in hex, colon-separated: AA:BB:CC:DD:EE:FF. IPv6 addresses are eight groups of two bytes in hex. Port numbers and protocol values in Wireshark captures are hex.

File formats: Magic bytes identify file types. JPEG files start with FF D8 FF. PNG files start with 89 50 4E 47. ZIP files start with 50 4B 03 04. Knowing hex lets you verify files are what they claim to be by inspecting raw bytes in a hex editor.

Embedded systems and hardware: Register maps, interrupt vectors, DMA addresses, peripheral base addresses โ€” all hex. Microcontroller datasheets live in hex.

Quick Mental Math Tips

A few values worth memorizing: 0x0F = 15 (useful as a bitmask for low nibble). 0x80 = 128 (the sign bit in an 8-bit byte). 0xFF = 255 (all bits set in a byte). 0x100 = 256. 0xFFFF = 65535. 0x7FFFFFFF = 2,147,483,647 (max 32-bit signed). 0xFFFFFFFF = 4,294,967,295 (max 32-bit unsigned). These boundaries come up constantly in programming, and recognizing them on sight saves real time.

Also handy: multiplying by 16 in hex is just appending a zero, exactly like multiplying by 10 in decimal. 0xA ร— 16 = 0xA0. And dividing by 16 is just dropping the last hex digit (if there's no remainder).

The converter above handles all of this automatically โ€” BigInt arithmetic under the hood means it works correctly on arbitrarily large numbers, not just 32-bit or 64-bit values. Paste in a 128-bit number and it'll group it cleanly. The bit-width and nibble count metadata help you verify you're working with the right integer size for your target data type.

FAQ

What is the hexadecimal equivalent of 255?
255 in decimal equals FF in hexadecimal (or 0x00FF with the 0x prefix and 16-bit padding). This is because 15 ร— 16 + 15 = 255, and the digit 15 is represented as F in hex. It is also the maximum value of a single unsigned byte, which is why 0xFF appears everywhere in binary data.
Why does the converter pad hex values with leading zeros?
Hex values are padded to the nearest nibble boundary (multiple of 4 hex digits, representing a multiple of 16 bits) so you can immediately see the bit width of the value. For example, 10 decimal becomes 000A rather than just A, making it clear this fits in 16 bits. This also makes nibble grouping meaningful โ€” groups of 4 digits always represent 16-bit words cleanly.
What does the 0x prefix mean in hexadecimal?
The 0x prefix is a notation convention โ€” it stands for 'hexadecimal' and signals to both humans and programming language parsers that the following digits are base-16 rather than decimal. It originated in the C programming language and is now standard in nearly every modern language including JavaScript, Python, Java, Rust, and Go. The x in 0x literally stands for 'hex'.
How do I convert a large decimal number like 4294967295 to hex manually?
You use repeated division by 16, recording the remainder at each step, then read the remainders in reverse. For 4294967295: 4294967295 รท 16 = 268435456 r 15 (F), 268435456 รท 16 = 16777216 r 0, and so on. Each remainder gives one hex digit. However, for large numbers this is tedious โ€” the converter above uses JavaScript BigInt to handle arbitrarily large values instantly and accurately.
How are negative numbers represented in hexadecimal?
There are two common conventions. The mathematical convention (used by this converter) is simply to prepend a minus sign: -255 becomes -0x00FF. The hardware convention used in CPUs and most programming languages is two's complement: in this scheme, -1 in 32-bit is 0xFFFFFFFF and -128 in 8-bit is 0x80. Which interpretation applies depends entirely on the context โ€” always check the bit width and whether the value is signed or unsigned when working with hardware registers or low-level code.
Is hex uppercase or lowercase โ€” which should I use?
Both are mathematically identical. Uppercase (Aโ€“F) is traditional and common in hardware documentation, hex dumps, and assembly language. Lowercase (aโ€“f) is preferred in CSS color values, many style guides (Go, Python's hex() built-in), and web contexts. Use whichever matches the target context โ€” the converter provides an uppercase toggle so you can match either convention.