Number base converter

Convert between binary, octal, decimal, hex and base 36 with exact BigInt arithmetic, a two's complement view at 8 to 64 bits, and prefixes like 0x and 0b understood on input.

Decimal
Hex
Octal
Base 36
Binary
Bytes needed2
Register width
Two's complement, 32-bit
Bits
Everything here is a BigInt, so a 64-bit id or a hash converts exactly. JavaScript's own Number loses precision above 2^53, which is where most base converters quietly go wrong.

Questions

Why BigInt?+

JavaScript's Number is a 64-bit float and loses integer precision above 2^53, which is smaller than a 64-bit id or a hash. BigInt has no limit, so a long hex string converts exactly instead of ending in a run of zeros.

What does the two's complement row show?+

The bit pattern a register of the chosen width would hold, which is how a negative number is stored and why -1 reads as 0xFF in eight bits. If the value needs more bits than the width, the tool says so and shows the wrapped value.

Can I paste 0xFF or 1_000_000?+

Yes. A 0x, 0b or 0o prefix sets the base regardless of the picker, and underscores or spaces between digits are ignored, so a number copied out of source code works as it is.

Related tools

The tools are free. So is most of the library.

2095 blocks and 1076 pieces for shadcn/ui and Tailwind, built on the same tokens these tools write. Install one with a command and the code is yours.

No signup for the tools. MIT for free blocks, commercial licence for Pro.

Markdown version