Number base converter (binary, decimal, hex)
Every base writes the same number with a different set of digits: 255 in decimal is 11111111 in binary, 377 in octal and FF in hexadecimal. Type a number in any base from 2 to 36 to see it in all the others, exactly, up to 10,000 digits long.
In hexadecimal
FF
255 decimal · 11111111 binary
- Binary (base 2)
- 11111111grouped: 1111 1111
- Octal (base 8)
- 3770o377
- Decimal (base 10)
- 255
- Hexadecimal, uppercase
- FF0xFF
- Hexadecimal, lowercase
- ff0xff
- Base 36
- 73digits 0–9 then a–z, as JavaScript's toString(36) writes them
- Binary digits
- 8 bits
- Bytes needed
- 1 byte
- Smallest unsigned type
- 8-bit (uint8, 0 to 255)
- Smallest signed type
- 16-bit (int16, -32,768 to 32,767)
How do you convert a number from one base to another?
Each digit is worth its value times a power of the base, counted from 0 at the right. In decimal, 255 is 2 × 100 + 5 × 10 + 5 × 1; in hexadecimal, FF is 15 × 16 + 15 × 1, which is also 255; in binary, 11111111 is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1. Bases above 10 borrow letters for the extra digits, so A is 10, F is 15 and Z is 35, which is why base 36 is the largest that fits 0–9 and A–Z.
To write a number in another base, divide it by that base again and again and read the remainders from last to first. 255 ÷ 16 is 15 remainder 15, and 15 ÷ 16 is 0 remainder 15, giving F and F: FF. Binary, octal and hex also map straight onto each other, because one hex digit is exactly four bits and one octal digit exactly three.
JavaScript's regular numbers can only hold whole numbers exactly up to 9,007,199,254,740,991 (2^53 − 1); above that, neighbouring integers round to the same value. This converter uses BigInt instead, so every digit of a large number is exact. Negative numbers keep their minus sign in every base, as JavaScript's toString does, and the result also shows the two's complement bit pattern that a fixed-width signed integer stores.
value = dₙ × baseⁿ + … + d₂ × base² + d₁ × base + d₀ FF₁₆ = 15 × 16 + 15 = 255₁₀ 255 ÷ 16 = 15 r 15, 15 ÷ 16 = 0 r 15 → FF
What are 0 to 16 and the powers of two in binary, octal and hex?
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 3 | 11 | 3 | 3 |
| 4 | 100 | 4 | 4 |
| 5 | 101 | 5 | 5 |
| 6 | 110 | 6 | 6 |
| 7 | 111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 32 (2⁵) | 100000 | 40 | 20 |
| 64 (2⁶) | 1000000 | 100 | 40 |
| 128 (2⁷) | 10000000 | 200 | 80 |
| 256 (2⁸) | 100000000 | 400 | 100 |
| 1,024 (2¹⁰) | 10000000000 | 2000 | 400 |
| 4,096 (2¹²) | 1000000000000 | 10000 | 1000 |
| 65,536 (2¹⁶) | 10000000000000000 | 200000 | 10000 |
| 4,294,967,296 (2³²) | 100000000000000000000000000000000 | 40000000000 | 100000000 |
How to convert a number between bases
- 1Type the numberEnter it as you have it: 255, FF, 0xFF, 1111_1111 or -42. Spaces and underscores between digits are ignored.
- 2Say which base it is inPick decimal, binary, octal or hexadecimal, or another base from 2 to 36. A 0x, 0b or 0o prefix is read for you.
- 3Read every base at onceThe result lists binary, octal, decimal, hex in both cases and base 36, plus any extra base you ask for, each with a copy button.
- 4Check its sizeSee how many bits and bytes it needs and the smallest unsigned and signed integer types it fits.
Frequently asked questions
How do I convert binary to decimal?
How do I convert decimal to hexadecimal by hand?
Why does JavaScript get large numbers wrong?
What do 0x, 0b and 0o mean in front of a number?
How are negative numbers written in binary?
Sources
- MDN, BigInt (arbitrary-size integers; creating them from "0x", "0o" and "0b" strings) (checked 20 Oct 2026)
- MDN, BigInt.prototype.toString() (radix 2 to 36, letters above 9, sign kept rather than two's complement) (checked 20 Oct 2026)
- MDN, Number.prototype.toString() (radix 2 to 36) (checked 20 Oct 2026)
- MDN, Number.MAX_SAFE_INTEGER (9,007,199,254,740,991) (checked 20 Oct 2026)
- MDN, Lexical grammar: numeric literals (0b, 0o, 0x prefixes, legacy leading-zero octal, _ separators) (checked 20 Oct 2026)
Need a custom dev tool for your team?
We build internal tools, dashboards, APIs, and SaaS platforms. If you can describe it, we can ship it.
Built by CountryDevs · No signup · No ads · We count visits, never what you enter