Number base converter

Runs locally

Binary, octal, decimal and hex — exact for any size, with two's complement views.

Number

A 0x, 0b or 0o prefix overrides the selected base. Underscores, spaces and commas between digits are ignored.

In every base

32-bit magnitude

Binary1101 1110 1010 1101 1011 1110 1110 1111
Octal33 653 337 357
Decimal3,735,928,559
HexadecimalDEAD BEEF

Fixed-width integers

The same bits read as unsigned and as two's complement signed

WidthHexUnsignedSigned
8-bitDoes not fit in 8 bits
16-bitDoes not fit in 16 bits
32-bitDEAD BEEF3735928559-559038737
64-bit0000 0000 DEAD BEEF37359285593735928559
Guide

Why a hex converter needs more than parseInt

JavaScript numbers are 64-bit floats, so parseInt('FFFFFFFFFFFFFFFF', 16) returns 18446744073709552000 — close, and wrong. That matters for exactly the numbers developers convert most: 64-bit IDs, hashes, memory addresses and bit masks. This converter works on BigInt throughout, so a 64-bit or 256-bit value converts digit for digit.

The fixed-width table answers the other common question: what does this bit pattern mean as a signed integer? The same eight bits, 11001000, are 200 as an unsigned byte and -56 as a signed one. Seeing both side by side is how you debug an overflow, a sign-extension bug or a checksum that came back negative.

Input (hex)

0xFFFFFFFE

Read back

Binary       1111 1111 1111 1111 1111 1111 1111 1110
Decimal      4,294,967,294
32-bit       unsigned 4294967294 · signed -2
64-bit       unsigned 4294967294 · signed 4294967294

The same value is -2 as a signed 32-bit integer and 4294967294 as a 64-bit one. That difference is a classic source of bugs when a 32-bit field is read into a wider type.

Where people get caught

A leading zero once meant octal

In old JavaScript, C and many config parsers, 010 is eight, not ten. File modes like 0755 are octal for this reason. Use an explicit 0o prefix where the language allows it.

Doubles are exact only up to 2^53

Integers above 9,007,199,254,740,991 cannot all be represented as JavaScript numbers. IDs from 64-bit databases should travel as strings or BigInt, never as plain JSON numbers.

Negative hex depends on the width

-1 is FF in 8 bits, FFFF in 16 and FFFFFFFF in 32. A bare '-0x1' has no fixed width, which is why the table shows each width separately.

About number base conversion

How it works in 5 steps · 4 common use cases · 4 questions answered

How it works

  1. 1.Pick the base you are typing in, or use a 0x, 0b or 0o prefix.
  2. 2.Type the number. Separators like _, spaces and commas are ignored.
  3. 3.Read it in binary, octal, decimal and hex, optionally grouped.
  4. 4.Check the 8-, 16-, 32- and 64-bit rows for its unsigned and two's complement values.
  5. 5.Copy any representation with its prefix.

Common use cases

  • •Reading a hex error code or memory address as a decimal number
  • •Checking a bit mask or permission flags in binary
  • •Converting 64-bit IDs without losing precision
  • •Debugging a signed/unsigned overflow

FAQ

Is there a size limit?

No practical one. Conversion uses BigInt, so a 256-bit hash converts as exactly as a single byte.

What is two's complement?

The way almost every CPU stores negative integers: the top bit has a negative weight. It is why 0xFF is -1 as a signed byte and 255 as an unsigned one.

Can I enter negative numbers?

Yes, with a leading minus in any base. The fixed-width rows then show the two's complement bit pattern for each width it fits in.

Does it support fractions or floating point?

No. It converts integers only. Fractional values in another base are rarely exact and are better handled by a float inspector.