Solved.tools — Free Online Calculators & Tools

We use cookies for analytics and advertising. Learn more about our cookie policy

Hex to Decimal Converter

Last updated: 22 August 2026

Reviewed by Gavin · Research and drafting assisted by AI

Quick reference: 0xFF = 255 | 0x100 = 256 | 0xDEAD = 57,005 | 0xCAFEBABE = 3,405,691,582 | 0xFFFFFFFF = 4,294,967,295
Was this helpful?


Hex to Decimal Converter

Hexadecimal (base 16) is the canonical notation for any byte-aligned value in computing. Memory addresses, MAC addresses, IPv6 fragments, CSS colour codes, Unicode code points, and Java class-file magic numbers all default to hex because each hex digit encodes exactly four binary bits, a byte is two hex digits, a 32-bit word is eight, a 64-bit pointer is sixteen. This tool converts any hex string you paste into its decimal equivalent (and binary and octal alongside it) with strict input validation, an optional 0x prefix, and tolerance for whitespace inside the value.

How to Use

  1. Paste a hex value into the input box. Allowed characters are 0-9, a-f, and A-F. The leading 0x or 0X prefix is optional; whitespace inside the value is removed automatically.
  2. Click Convert (or press Enter). The decimal value appears immediately, alongside the canonical uppercase hex, the binary representation, the octal representation, and the bit length.
  3. Use the table for cross-checks: if you convert 255 decimal to hex you should get FF, and if you convert FF hex back to decimal you should get 255. The round trip is exact.
  4. For values larger than 16 hex digits, the tool refuses with a clear message, the JavaScript Number.MAX_SAFE_INTEGER boundary is sixteen F's. For UUIDs and IPv6 addresses, use the dedicated converter.

The Formula

The conversion is a single parseInt call against base 16, followed by three toString calls to express the same integer in binary, octal, and (canonicalised) hex:

decimal = parseInt(hex_clean, 16)
binary  = decimal.toString(2)
octal   = decimal.toString(8)
hex_canonical = decimal.toString(16).toUpperCase()
bits    = binary.length

The parseInt(string, radix=16) operation is defined by ECMA-262 Section 21.1.3.18. It strips a leading 0x or 0X automatically, ignores leading whitespace, accepts an optional sign, and stops parsing at the first character that is not a valid digit in the given radix. For hex, the valid digits are 0-9 and a-f (case-insensitive); the first non-hex character terminates the parse. So parseInt("FFG", 16) returns 255 and silently ignores the G, this tool replaces that behaviour with strict validation by pre-checking the input against the regex /^[0-9a-fA-F]+$/ before parsing, so a stray character produces a visible error instead of a wrong answer.

The reverse direction (decimal to hex) is the same integer with .toString(16). Because toString always returns lowercase, the canonical form (RFC 5952 for IPv6) is obtained by upper-casing the result.

The bit length is the binary string's length. For example, 255 is 11111111 (eight bits), so the displayed bit length is 8; 65535 is 1111111111111111 (sixteen bits); 16777215 is 111111111111111111111111 (twenty-four bits). The number of hex digits required to express a value is ceil(bits / 4), so an 8-bit value always needs two hex digits, a 16-bit value always needs four, and so on.

Worked Examples

1. Single byte: FF → 255. The maximum value of an unsigned 8-bit byte. Common as the alpha channel maximum in CSS colour codes (#FFxxxx means full opacity), as the fill byte for empty memory regions in debugger output, and as the largest valid port number plus one (port 65535 is 0xFFFF, the largest 16-bit unsigned value).

2. Two bytes (16-bit): DEAD → 57,005. A classic demo-program magic value, picked because DEAD in hex is memorable and prints as 0xDEAD in debuggers. The same trick gives BEEF (48,879), BABE (47,806), FACE (64,206), and F00D (61,453). These are mnemonics, not technical constants, but they show up so often in hex dumps that any developer who has used a debugger will recognise them on sight.

3. Four bytes (32-bit): CAFEBABE → 3,405,691,582. The Java class-file magic number. Every compiled .class file begins with these four bytes; tools that read class files check the magic first to confirm the file is actually a class file before parsing anything else. The choice of CAFEBABE was deliberate, it stands out in a hex dump and is unlikely to collide with any other format's magic number.

4. With prefix: 0x100 → 256. The optional 0x prefix is stripped automatically before parsing. C, C++, Java, JavaScript, Python, Rust, Go, and every other major language use 0x as the hex prefix; some assembly languages use h as a suffix (FFh); some old-style Unix tools use :h (FF:h was a Multics convention). The tool accepts 0x and 0X and ignores any other prefix syntax.

5. With whitespace: DE AD BE EF → 3,735,928,559. Whitespace inside the value is removed before parsing. This is convenient because hex dumps from debuggers traditionally group bytes by four (DEAD BEEF) or by eight (DEADBEEF CAFEBABE). Paste either form and the tool handles it.

Where It Shows Up

Hex shows up anywhere a byte-aligned value needs to be printable: memory addresses in debugger output (0x7FFE34A0), MAC addresses on network hardware (00:1A:2B:3C:4D:5E), IPv6 address fragments (2001:0db8:85a3::8a2e:0370:7334), HTML and CSS colour codes (#FF5733), Unicode code points (U+0041 for A), Java class-file magic (CAFEBABE), PNG image headers (89504E47), gzip headers (1F8B), SHA-256 hash digests (every block of 8 hex chars), GUIDs/UUIDs (32 hex chars total), and the raw bytes of any binary blob that has to be transmitted through a text-only channel (email bodies, JSON values, URLs after percent-encoding).

For colour codes specifically, a six-digit hex value like #RRGGBB breaks into three two-digit hex components, the red channel, the green channel, and the blue channel, each ranging from 00 (zero intensity) to FF (full intensity). This tool's quick-reference table includes 0xFF5733 as an example: 255 red, 87 green, 51 blue, which is a warm orange.

Common Mistakes

1. Treating parseInt as strict. The native parseInt("FFG", 16) returns 255 and silently ignores the G. This tool's strict input validation pre-checks the entire string against /^[0-9a-fA-F]+$/ before parsing, so a typo produces a visible error instead of a wrong answer. If you copy a hex value out of a hex dump and the dump has a trailing comma or space, strip it before pasting, the strict mode rejects the value rather than silently truncating at the bad character.

2. Confusing signed and unsigned. A byte can hold 0-255 (unsigned) or -128 to 127 (signed, two's-complement). This tool always returns the unsigned interpretation. If your source says 0xFF means -1 (the signed-byte convention) or 0x80 means -128, subtract 256 from the unsigned result. For 16-bit signed values, subtract 65536; for 32-bit, subtract 4294967296.

3. Going beyond the 64-bit safe range. JavaScript's Number.MAX_SAFE_INTEGER is 9007199254740991, which is 0x1FFFFFFFFFFFFF (13 F's). Beyond that, integer precision is lost: 0x20000000000001 and 0x20000000000002 parse to the same JavaScript Number. This tool caps inputs at 16 hex digits (which is 0xFFFFFFFFFFFFFFFF, the full 64-bit unsigned range) to avoid silently producing wrong values. For 128-bit values (UUIDs, IPv6 addresses, SHA-512 hashes), use a tool that uses BigInt internally rather than Number.

4. Stripping leading zeros by accident. Hex values like 0x0001 and 0x01 and 0x1 all represent the same integer. The tool's canonical form is 0x followed by the uppercase hex with no leading zeros, so 0x0001 becomes 0x1. This is correct for arithmetic but may surprise you if you were expecting fixed-width formatting, for fixed-width hex (like dumping a 32-bit register), use a different tool that pads to the byte count.

5. Forgetting the 0x prefix when sharing. Hex values without a prefix can be mistaken for decimal, octal, or identifier names. The C convention is 0xFF; the Python convention is 0xFF; the assembly convention varies (FFh on x86, $FF on Motorola 68000, x'FF' on IBM mainframe assembler). Always include the prefix when sharing a hex value with someone else, unless the context is unambiguous (a colour code, an IP address, a hash digest).

Frequently Asked Questions

Q: What does 0x mean at the start of a hex number? A: The 0x (zero-x) prefix is a notation convention that marks the following digits as base-16 rather than base-10. It was introduced by C in the 1970s and is now used by Java, JavaScript, Python, Go, Rust, Ruby, and every other major C-family language. The 0 marks it as a numeric literal rather than an identifier, and the x marks the radix as hexadecimal (the literal x is mnemonic for the unknown digit set, which is 0-9 and a-f). The tool accepts both 0x and 0X and strips them before parsing.

Q: How do I convert decimal to hex? A: Use the general-purpose Number Base Converter on this site, pick decimal as the source base and hex as one of the target bases. The math is value.toString(16), which gives lowercase hex; uppercase with .toUpperCase(). For example, 255.toString(16) returns "ff", (255).toString(16).toUpperCase() returns "FF". The reverse direction, hex to decimal, is what this tool does: parseInt("FF", 16) returns 255.

Q: Why is the maximum input 16 hex digits? A: Sixteen hex digits encode 64 binary bits, which is the full unsigned 64-bit range (0 to 18446744073709551615). Beyond that, JavaScript's Number type cannot represent every integer exactly because Number is a double-precision float with only 53 bits of mantissa precision. The tool caps at 16 hex digits so that the displayed decimal value is always a faithful representation of the input. For 128-bit values (UUIDs, IPv6, SHA-512), use a BigInt-based tool instead.

Q: Can this converter handle negative numbers? A: Not directly. The input is parsed as a non-negative integer in the unsigned range 0 to 0xFFFFFFFFFFFFFFFF. If you need to interpret a hex value as a signed integer (two's-complement), subtract 2^n from the result where n is the bit width: 8 bits → subtract 256, 16 bits → subtract 65536, 32 bits → subtract 4294967296, 64 bits → subtract 18446744073709551616. For example, 0xFFFFFFFF (32-bit) returns 4294967295 from this tool; as a signed 32-bit value, it represents -1.

Q: What is the difference between hex and Unicode code points? A: Hex is a numeral system (base 16) used to write any non-negative integer. Unicode code points are a mapping from integers to abstract characters; the canonical notation for a code point is U+ followed by the hex value (typically four or more digits, zero-padded). For example, the Latin capital letter A is code point 65 (decimal) or 41 (hex), written as U+0041 in canonical form. This tool will convert 0041 to decimal 65 correctly because leading zeros are ignored, the output is 0x41 not 0x0041, but the value is the same.

Q: Is this converter suitable for cryptographic or security-sensitive work? A: This is a display utility, not a cryptographic primitive. The hex-to-decimal conversion is exact and deterministic for all values in the supported range, so it is fine for reading hex digests of known files, memory addresses in your own code, MAC addresses of your own devices, and other non-secret data. It is not appropriate for converting secret keys, password hashes, or HMAC outputs in a context where an attacker might observe the conversion, those should use a vetted cryptographic library on a trusted machine with the secrets handled in memory only. The tool runs entirely in your browser and does not transmit your input anywhere, but the standard "don't paste secrets into web tools" caution still applies.

Q: Can the Hex to Decimal Converter, Hex ⇄ Decimal + Binary + Octal be used for professional or commercial purposes? used for professional or commercial purposes? A: Yes, the Hex to Decimal Converter, Hex ⇄ Decimal + Binary + Octal provides mathematically correct results that are suitable for professional, commercial, and educational use. For the Hex to Decimal Converter, Hex ⇄ Decimal + Binary + Octal, For the Hex to Decimal Converter, Hex ⇄ Decimal + Binary + Octal, For high-stakes applications (medical, legal, financial), verify results with a domain expert. For the Hex to Decimal Converter, Hex ⇄ Decimal + Binary + Octal, the Hex to Decimal Converter, Hex ⇄ Decimal + Binary + Octal formulas used are well-established and validated against reference standards.

How often are the Hex to Decimal Converter, Hex ⇄ Decimal + Binary + Octal formulas updated?⇄ Decimal + Binary + Octal formulas updated? For the Hex to Decimal Converter, Hex ⇄ Decimal + Binary + Octal, A: the Hex to Decimal Converter, Hex ⇄ Decimal + Binary + Octal formulas are based on established scientific, mathematical, or industry-standard references and rarely require updates. When standards change (e.g., new physical constants, revised tax brackets, updated standards), the Hex to Decimal Converter, Hex ⇄ Decimal + Binary + Octal is updated to reflect the current authoritative source. For the Hex to Decimal Converter, Hex ⇄ Decimal + Binary + Octal, Each calculator's references section lists the specific sources used.

References

  • ECMA-262, ECMAScript Language Specification, Section 21.1.3.18 parseInt(string, radix), defines the parsing semantics for radix-based integer conversion in JavaScript and every other ECMA-262-compliant runtime.
  • IEEE 754, Standard for Floating-Point Arithmetic, defines the 64-bit double-precision representation used by JavaScript's Number type, including the MAX_SAFE_INTEGER = 2^53 - 1 = 0x1FFFFFFFFFFFFF boundary.
  • ISO/IEC 9899, C Programming Language Standard, Section 7.8.2.3 strtoul and 7.8.2.4 strtoull, defines the parsing semantics for 0x-prefixed hex literals in C, which parseInt mimics.
  • RFC 5952, A Recommendation for IPv6 Address Text Representation, IETF, defines the canonical lowercase-no-leading-zeros form for IPv6 address hex groups (this tool uppercases for visibility but the canonical form is lowercase).
  • RFC 20, ASCII Format for Network Interchange, IETF, defines the ASCII character set that this tool's byte-level examples reference.
  • Java Class File Format Specification, Chapter 4, The Class File Format, Oracle, documents the CAFEBABE magic number that every compiled .class file begins with.