Number Base Converter

Convert between binary, octal, decimal, hexadecimal and any base from 2 to 36 — with two's complement, bit width and overflow shown for the value you enter.

Equivalent values

Conversions use arbitrary-precision arithmetic, so values beyond the usual JavaScript limit stay exact. Everything runs locally in your browser.

What It Does

A number base is simply how many digits you count with before carrying to the next column. Decimal uses ten, binary two, hexadecimal sixteen. The quantity never changes when you convert — 255, ff and 11111111 are the same number written three ways — but which representation you want depends on what you are doing with it. This tool converts a value between all the common bases at once, and any base from 2 to 36 on request. Where it goes further than most converters is in what it tells you about the number afterwards: how many bits it actually occupies, which register widths it fits in, and what bit pattern a machine would store for it including the two's complement form when it is negative. Those are the details that turn a conversion into an answer to the question you were really asking.

When to Use It

  • You are reading a memory dump or a debugger and need the decimal meaning of a hex value before it makes any sense.
  • A bit mask or set of permission flags is written in hex and you want to see which individual bits are actually set.
  • You hit an integer overflow and need to confirm whether the value genuinely exceeds what a 32-bit signed field can hold.
  • You are working with a negative value in a binary protocol and need the exact two's complement bit pattern at a specific width.
  • You want a compact base-36 identifier from a numeric id for use in a short URL.

Worked Examples

255

The classic byte boundary. In hex it is ff and in binary 11111111 — every bit set. It is the largest value an unsigned 8-bit field holds, which is why adding one more wraps it back to zero.

-1

The value that shows why width matters. Written signed it is just -1, but the bit pattern a machine stores is all ones, and how many ones depends entirely on whether the register is 8, 16, 32 or 64 bits wide.

3735928559

Convert this to hex and it reads deadbeef — one of the magic numbers programmers historically wrote into memory to make uninitialised data obvious in a dump. A good demonstration of why hex is easier to recognise than decimal.

Features

Live conversion between binary
octal
decimal and hexadecimal
Any base from 2 to 36 supported
Arbitrary precision using BigInt with no upper limit
Two's complement shown at 8
16
32 and 64 bits
Signed and unsigned range checking per width
Bit length of the entered value
Accepts 0x
0b and 0o prefixes and grouped digits
Strict parsing that names an invalid digit rather than guessing
One-click copy for every representation
Runs entirely in your browser

How to Use

1. Type a value into the input box and select which base it is currently written in. 2. The equivalent in binary, octal, decimal and hexadecimal appears immediately. 3. Set the custom base selector for any other base between 2 and 36. 4. Choose a bit width to see the two's complement pattern a machine would store. 5. Use the copy button beside any representation to put it on your clipboard.

Common Mistakes

  • Assuming a negative number has one binary representation. It does not — the two's complement pattern depends on the register width, and quoting one without the other is meaningless.
  • Trusting a browser converter with a full 64-bit value. Most use ordinary JavaScript numbers and lose precision above about nine quadrillion, returning a plausible but wrong result with no warning at all.
  • Mixing up the signed and unsigned range of the same width. An 8-bit field holds either -128 to 127 or 0 to 255, never both, and reading a byte with the wrong assumption turns 200 into -56.
  • Reading a leading zero as significant. In most languages a leading 0 on an integer literal historically meant octal, so 010 is 8 rather than 10 — a genuinely nasty source of bugs in older code.
  • Confusing a hex digit with a byte. One hex digit is four bits, so a byte is always two digits — an odd-length hex string is missing a leading zero somewhere.

Frequently Asked Questions

Explore related topics

#Converter