Number Base Converter
Convert between binary, octal, decimal, hexadecimal, and any base from 2 to 36. Exact for huge values, with negative numbers and two’s complement.
Open source on GitHubNumber
Whole numbers of any size. A leading minus sign, 0x / 0b / 0o prefixes, and spaces or underscores between digits are fine.
Result
Hexadecimal (base 16)
7 E8
Binary (base 2)
111 1110 1000
Octal (base 8)
3 750
Decimal (base 10)
2,024
11 bits · 4 decimal digits
Two’s complement
Bit pattern
0000 0000 0000 0000 0000 0111 1110 1000
Hex
0x00 00 07 E8
As signed integer
2,024
As unsigned integer
2,024
Runs entirely in your browser. Nothing you type here is uploaded or stored.
Converting 2024 to hex, step by step. Repeated division works for any target base.
| Step | Calculation | Result |
|---|---|---|
| 1. Divide by the target base | 2024 ÷ 16 = 126, remainder 8 | Lowest digit: 8 |
| 2. Divide the quotient again | 126 ÷ 16 = 7, remainder 14 | Next digit: E (14) |
| 3. Repeat until the quotient is 0 | 7 ÷ 16 = 0, remainder 7 | Highest digit: 7 |
| 4. Read remainders bottom to top | 7, E, 8 | 2024 = 0x7E8 |
| 5. Check by expanding | 7 × 16² + 14 × 16 + 8 = 1792 + 224 + 8 | 2024 ✓ |
Counting from 0 to 16 in four bases. Each hex digit maps to exactly four binary digits.
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 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 | 1 0000 | 20 | 10 |
How to write each base in code. Literal prefixes by language.
| Base | Literal | Where it works |
|---|---|---|
| Binary (2) | 0b1010 | JavaScript, Python, Java 7+, C23, C++14, Rust, Go, Swift |
| Octal (8) | 0o12 | JavaScript, Python 3, Rust, Swift, Go 1.13+. C, Java, and older code use a bare leading 0 (012), a common source of bugs. |
| Hexadecimal (16) | 0xA | Almost every language. CSS colors use # (#0A0A0A); assembly listings often use a trailing h (0Ah). |
| Any base | parseInt("z", 36) | JavaScript parseInt(text, radix) and Number.prototype.toString(radix) accept bases 2–36; Python has int(text, base). |
More free tools. Free, open source, no sign-up. See all tools · Source on GitHub
Frequently asked questions
How do I convert a number from one base to another?
Divide the number by the target base again and again, writing down each remainder, until the quotient reaches 0. The remainders read from last to first are the digits in the new base. To go the other way, multiply each digit by the base raised to its position and add the results. This converter does both instantly for any base from 2 to 36.
Why do bases stop at 36?
Base 36 uses all ten digits plus the 26 letters A–Z, so it is the largest base you can write with ordinary alphanumeric characters. It is used for short IDs and URL shorteners. Letters are case-insensitive here, so ff and FF are the same hex value.
Can it convert very large or negative numbers?
Yes. Values are stored as JavaScript BigInt, so a 40-digit decimal number converts without the rounding you get above 2^53 with regular numbers. Negative numbers keep their minus sign in every base, and the two’s complement panel shows how a computer stores them in 8, 16, 32, or 64 bits.
What is two’s complement?
Two’s complement is how computers store signed integers. A negative number −n is stored as 2^bits − n, so −1 in 8 bits is 11111111 (0xFF) and −128 is 10000000. The same bit pattern can be read as signed or unsigned, which is why the panel shows both. If a value needs more bits than the width you choose, it is flagged as an overflow.
Does it convert fractions?
No, this converter handles whole numbers only. Fractions such as 0.1 often have no exact representation in binary, so converting them means choosing a precision. Most bug-hunting uses of base conversion, such as error codes, flags, and IDs, are integers.