Layerbit
Runs entirely in your browser

Number Base Converter: Binary, Hex, Decimal

Convert integers of any size between binary, octal, decimal, hexadecimal and any base up to 36, then inspect the same value as two's-complement bits you can toggle, big- and little-endian bytes, and IEEE-754 floats, with a bitwise calculator alongside.

Number
Bits & bytes
Bitwise & arithmetic calculator
Operands accept the same notation as the converter. NOT, and shifts with a fixed width, use the bit width chosen above (auto picks the smallest standard width that fits).

How positional number bases work

A base, or radix, is the number of distinct digits a system uses. In base 10 each position is worth ten times the one to its right; in base 2 each is worth twice as much, so 1011 is 8 + 0 + 2 + 1 = 11. Hexadecimal, base 16, uses the digits 0–9 and then A–F for ten to fifteen. It is popular in computing because one hex digit is exactly four bits, so a byte is always two hex digits and a 32-bit value is eight: 0xDEADBEEF is far easier to read than its 32 binary digits. Octal, base 8, maps three bits per digit and survives in Unix file permissions such as chmod 755.

Converting between any two bases means reading the digits into a single integer and writing it back out in the target base. This tool does that with JavaScript's BigInt, so there is no upper limit and no rounding: a 256-bit hash, a 20-digit account number or 264−1 converts exactly. Regular JavaScript numbers lose precision above 253, which is why pasting a large ID into many converters silently changes its last digits.

Two's complement and fixed widths

Computers store integers in a fixed number of bits, and almost all of them represent negative numbers with two's complement: the most significant bit carries a negative weight. In 8 bits, 11111111 is 255 read as unsigned but −1 read as signed, and 10000000 is 128 or −128. The same bit pattern means different things depending on the type you read it as, which is the source of many overflow bugs. The bits panel shows both readings at the chosen width, flags values that do not fit, and lets you flip individual bits to see the effect, which is useful when working with flags, masks and hardware registers.

WidthUnsigned rangeSigned rangeCommon type
8-bit0 to 255−128 to 127uint8 / int8, byte, char
16-bit0 to 65,535−32,768 to 32,767uint16 / short, UTF-16 code unit
32-bit0 to 4,294,967,295−2,147,483,648 to 2,147,483,647uint32 / int, IPv4 address, Unix time (signed)
64-bit0 to 18,446,744,073,709,551,615±9.22 × 1018uint64 / long, database BIGINT

Byte order

A multi-byte value has to be laid out in memory in some order. Big-endian puts the most significant byte first, the way we write numbers; it is the network byte order used by TCP/IP headers and most file formats. Little-endian puts the least significant byte first, and is what x86 and ARM processors use in memory. The value 0x12345678 is stored as 12 34 56 78 big-endian and 78 56 34 12 little-endian. When a hex dump of a file or packet does not match the number you expected, reversing the byte order is the first thing to try; both layouts are shown side by side.

Floating point bits

At 32 and 64 bits the same pattern can also be read as an IEEE-754 floating-point number, the format used by float and double in nearly every language. The bits split into a sign, an exponent and a mantissa. The panel decodes them and reports whether the value is normal, subnormal, zero, infinity or NaN. Use the decimal-to-bits field to see why 0.1 cannot be stored exactly: its float64 pattern is 0x3FB999999999999A, a repeating binary fraction rounded at the last bit, which is why 0.1 + 0.2 is not exactly 0.3.

Frequently asked questions

Multiply each hex digit by 16 raised to its position, counting from zero on the right, and add the results. For 0x2F3 that is 2 × 256 + 15 × 16 + 3 × 1 = 755, using A = 10 through F = 15. Typing 0x2F3, or 2F3 with the input base set to hex, into the converter shows 755 along with binary, octal and every other base, with no limit on the number of digits.

Negative integers are normally stored in two's complement at a fixed width. Write the positive value in binary, invert every bit, and add one. For −5 in 8 bits: 5 is 00000101, inverted 11111010, plus one is 11111011, which is 0xFB. Enter −5 and pick a width in the bits panel to see the two's-complement bits, the unsigned reading of the same bits (251 at 8-bit) and the bytes in both byte orders.

Most web converters and spreadsheets use 64-bit floating point numbers, which can represent every integer exactly only up to 2 to the power 53, about 9 quadrillion. Beyond that, digits are rounded, so a 19-digit Twitter/X or Discord snowflake ID, a 64-bit database key or a hash prefix comes back altered. This tool parses and formats with arbitrary-precision BigInt arithmetic, so every digit is preserved at any size.

Any integer base from 2 to 36, using the digits 0–9 followed by the letters A–Z. Binary, octal, decimal, hexadecimal and base 36 are always shown; set "Also show base" for another, for example base 3 or base 32. Input accepts 0x, 0b and 0o prefixes, an assembler-style h suffix in auto mode, and underscores, commas, spaces or apostrophes as digit separators, so values copied from code or documentation paste cleanly.

They are two readings of the same bits. Unsigned treats every bit as positive, so 8 bits hold 0 to 255. Signed two's complement gives the top bit a negative weight, so 8 bits hold −128 to 127. The pattern 11111111 is 255 unsigned and −1 signed. Bugs appear when a value written as one type is read as the other, for example a length of 200 stored in a signed byte reading back as −56.

No. Parsing, conversion, two's complement, byte order, float decoding and the calculator all run in JavaScript on this page. There are no network requests, and the page continues to work offline once it has loaded.

Changelog