# Number Base Converter - Binary, Octal, Decimal, Hex and Any Base from 2 to 36

Page: https://hirantha.me/tools/number-base-converter
Part of: Hirantha Sandaruwan Lakshan free tools (https://hirantha.me/tools)
Updated: 2026-10-15

Convert whole numbers between binary, octal, decimal, hex and any base from 2 to 36 with exact BigInt maths, negatives, two's complement and step-by-step working.

This is a free tool that runs in the browser: open the page to use it. File tools process files on the visitor's own device; files are never uploaded or stored. No account, sign-up, payment or watermark.

Type a whole number in any base from 2 to 36 and see it in binary, octal, decimal, hexadecimal and one more base of your choice. The maths uses BigInt, so a 200-bit number converts exactly instead of being rounded. Negative numbers are shown with a sign, and a table shows how the same value is stored in 8, 16, 32 and 64 bits in two's complement. Fractions are out of scope: this converter works with whole numbers only.

How place value works. In base b every digit is worth the digit times b raised to its position, counting from 0 on the right. The decimal number 255 is 2 x 10^2 + 5 x 10^1 + 5 x 10^0. The binary number 1010 is 1 x 2^3 + 0 x 2^2 + 1 x 2^1 + 0 x 2^0 = 8 + 2 = 10. Digits above 9 are written with letters, a for 10 up to z for 35, so hexadecimal needs a to f and base 36 uses the whole alphabet.

Converting by repeated division. To write a number in base b, divide it by b, keep the remainder, then divide the quotient again, until the quotient is 0. The remainders read from last to first are the digits. For 156 in binary: 156 / 2 = 78 r 0, 78 / 2 = 39 r 0, 39 / 2 = 19 r 1, 19 / 2 = 9 r 1, 9 / 2 = 4 r 1, 4 / 2 = 2 r 0, 2 / 2 = 1 r 0, 1 / 2 = 0 r 1, so the answer is 10011100. The tool lists these steps for any number below 2^32, and the positional expansion for the number you typed.

Why BigInt. An ordinary JavaScript number is a 64-bit floating point value that can represent every whole number exactly only up to 2^53 - 1, about 9 quadrillion. Past that, digits are silently lost. BigInt has no size limit, and BigInt.prototype.toString accepts any radix from 2 to 36, which is why this tool can show 2^200 as 1606938044258990275541962092341162602522202993782792835301376 and as a 1 followed by 200 zeros in binary. Input is limited to 4,000 digits to keep the page quick.

Negative numbers and two's complement. The main results show the sign and then the magnitude, so -255 is -11111111 in binary and -ff in hex. Computers store negative whole numbers differently: in n bits, a negative x is stored as 2^n + x, and the signed range is -2^(n-1) to 2^(n-1) - 1. So -5 in 8 bits is 256 - 5 = 251, which is 11111011 or FB. The table shows the pattern for 8, 16, 32 and 64 bits, says when a value does not fit, and for a pattern that fits only as unsigned, what it would mean if read as signed.

What you can type. Spaces and underscores between digits are ignored, and so are commas in decimal when they separate groups of three digits, so 1_000_000 and 1,000,000 both work. A comma anywhere else, as in 1,5, is refused rather than read as 15. A leading + or - is accepted. The prefixes 0x (hexadecimal), 0b (binary) and 0o (octal) switch the base for you, unless the letter is a real digit in the base you chose: in hexadecimal, 0b1 is the three digits 0, b and 1. An invalid digit is highlighted with the digits the base allows, and a decimal point is reported because fractions are not converted.

Powers of two, exact:
| Power | Decimal | Hexadecimal | Where you meet it |
| --- | --- | --- | --- |
| 2^0 | 1 | 0x1 | One value: a single bit set |
| 2^1 | 2 | 0x2 | Two values: one bit |
| 2^2 | 4 | 0x4 | Four values: two bits |
| 2^3 | 8 | 0x8 | Eight values: three bits, one octal digit |
| 2^4 | 16 | 0x10 | 16 values: four bits, one hexadecimal digit |
| 2^5 | 32 | 0x20 | 32 values |
| 2^6 | 64 | 0x40 | 64 values |
| 2^7 | 128 | 0x80 | 128 values |
| 2^8 | 256 | 0x100 | 256 values: one byte, 0 to 255 |
| 2^9 | 512 | 0x200 | 512 values |
| 2^10 | 1024 | 0x400 | 1,024: one kibibyte (KiB) in bytes |
| 2^11 | 2048 | 0x800 | 2,048 values |
| 2^12 | 4096 | 0x1000 | 4,096: a common memory page size in bytes |
| 2^13 | 8192 | 0x2000 | 8,192 values |
| 2^14 | 16384 | 0x4000 | 16,384 values |
| 2^15 | 32768 | 0x8000 | 32,768: one more than the largest signed 16-bit number |
| 2^16 | 65536 | 0x10000 | 65,536 values: two bytes, 0 to 65,535 |
| 2^20 | 1048576 | 0x100000 | One mebibyte (MiB) in bytes |
| 2^24 | 16777216 | 0x1000000 | 16,777,216 values: three bytes, the number of RGB colours |
| 2^30 | 1073741824 | 0x40000000 | One gibibyte (GiB) in bytes |
| 2^31 | 2147483648 | 0x80000000 | One more than the largest signed 32-bit number |
| 2^32 | 4294967296 | 0x100000000 | Four bytes: 4,294,967,296 values, the size of the IPv4 address space |
| 2^40 | 1099511627776 | 0x10000000000 | One tebibyte (TiB) in bytes |
| 2^53 | 9007199254740992 | 0x20000000000000 | One more than JavaScript's largest safe integer, 2^53 - 1 |
| 2^63 | 9223372036854775808 | 0x8000000000000000 | One more than the largest signed 64-bit number |
| 2^64 | 18446744073709551616 | 0x10000000000000000 | Eight bytes: the number of values in a 64-bit unsigned integer |
| 2^128 | 340282366920938463463374607431768211456 | 0x100000000000000000000000000000000 | The size of the IPv6 address space and of a UUID |
| 2^200 | 1606938044258990275541962092341162602522202993782792835301376 | 0x100000000000000000000000000000000000000000000000000 | Too big for a JavaScript number; shown exactly because this tool uses BigInt |

Q: How do I convert binary to decimal?
A: Write the place values 1, 2, 4, 8, 16 and so on from the right, and add the ones that sit under a 1. For 10011100 that is 128 + 16 + 8 + 4 = 156. The tool shows this expansion digit by digit for any number you type.

Q: How do I convert decimal to hexadecimal?
A: Divide by 16 repeatedly and keep the remainders, writing remainders 10 to 15 as A to F. 255 / 16 = 15 remainder 15, then 15 / 16 = 0 remainder 15, so the digits from last to first are F and F: 255 is FF. Set the division steps to base 16 to see it laid out.

Q: What is the biggest number this converter accepts?
A: Up to 4,000 digits in the number you type. BigInt itself has no fixed limit, but the cap keeps the page fast on a phone. A 4,000-digit decimal number is roughly 13,000 bits, far beyond the 64-bit integers most programs use.

Q: What is two's complement?
A: It is the way computers store signed whole numbers in a fixed number of bits. A negative x in n bits is stored as 2^n + x, so adding it to the matching positive number overflows to exactly zero. It gives one range, -2^(n-1) to 2^(n-1) - 1, and addition works the same for positive and negative values.

Q: Why does the converter show a minus sign instead of two's complement for negatives?
A: A base has no built-in sign, so the readable form is a minus sign followed by the magnitude, the same as BigInt.prototype.toString does. The width-specific two's complement patterns are in the table below the results, for 8, 16, 32 and 64 bits.

Q: Can it convert fractions such as 0.1 to binary?
A: No, this tool is limited to whole numbers and reports a decimal point as an error. Fractions need a different method, and many such as 0.1 repeat forever in binary, which is why 0.1 + 0.2 is not exactly 0.3 in floating point.

Q: Why do hexadecimal numbers use letters?
A: Base 16 needs sixteen digit symbols and there are only ten numerals, so the letters a to f stand for 10 to 15. Case does not matter: ff and FF are the same number. Hexadecimal is popular because one hex digit is exactly four bits, so a byte is two digits.

Q: What is base 36 used for?
A: Base 36 uses 0 to 9 and a to z, the largest base that needs only digits and letters of one case, so it writes a number in the fewest such characters. It is handy for short identifiers that encode a number. JavaScript's toString(36) and parseInt(text, 36) use the same digits, and so does this tool.

Sources: MDN: BigInt.prototype.toString, radix 2 to 36 (checked 15 October 2026) (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString); MDN: Number.MAX_SAFE_INTEGER, 2^53 - 1 (checked 15 October 2026) (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER); Wikipedia: Two's complement (checked 15 October 2026) (https://en.wikipedia.org/wiki/Two%27s_complement); NIST: Prefixes for binary multiples, kibi, mebi, gibi, tebi (checked 15 October 2026) (https://physics.nist.gov/cuu/Units/binary.html); RFC 791 Internet Protocol: addresses are 32 bits (checked 15 October 2026) (https://www.rfc-editor.org/rfc/rfc791.html); RFC 8200 IPv6 Specification: addresses are 128 bits (checked 15 October 2026) (https://www.rfc-editor.org/rfc/rfc8200.html); RFC 9562 UUIDs: 128 bits long (checked 15 October 2026) (https://www.rfc-editor.org/rfc/rfc9562.html)

Related tools:

- [Text to binary converter](https://hirantha.me/tools/text-to-binary.md): Turn text into binary, hexadecimal, octal or decimal bytes, and bytes back into text. UTF-8 aware, with an ASCII table and clear errors.
- [Chmod calculator](https://hirantha.me/tools/chmod-calculator.md): Tick read, write and execute boxes to get the chmod number and rwxr-xr-x string, read u+x style changes, work out a umask, and copy safe chmod and find commands.
- [Base64 encode & decode](https://hirantha.me/tools/base64.md): Convert text to Base64 and back, right in your browser.
- [Hash generator](https://hirantha.me/tools/hash-generator.md): Generate a SHA-1, SHA-256, SHA-384, or SHA-512 hash of text.
- [Colour converter](https://hirantha.me/tools/color-converter.md): Convert a colour between HEX, RGB, and HSL.
