Number Base Converter
Convert numbers between binary, octal, decimal, and hexadecimal in real time. All four bases are displayed simultaneously with standard prefix notation - entirely client-side, no data ever leaves your browser.
Try These Examples
- Decimal:
255- the maximum value of a single byte - Binary:
10101010- an alternating bit pattern - Hex:
1A3F- a typical hex value used in colour and memory addresses - Octal:
755- the classic Unix file permission
How It Works
Every number you use daily is written in a positional number system. In decimal (base 10), the number 365 means 3×102 + 6×101 + 5×100. The same principle applies to every other base - only the multiplier changes.
Positional Number Systems
In base b, each digit position represents a successive power of b, starting from the right at b0. Binary (base 2) uses powers of 2, so the binary number 1101 equals 1×8 + 1×4 + 0×2 + 1×1 = 13 in decimal. Octal groups three binary digits, and hexadecimal groups four, which is why they are natural shorthand for binary data.
JavaScript's parseInt() and toString()
This tool relies on two built-in JavaScript methods:
parseInt(string, radix)- parses a string and returns an integer, interpreting the digits according to the specified radix (2, 8, 10, or 16).Number.prototype.toString(radix)- converts a number to a string representation in the given base. For example,(255).toString(16)returns"ff".
By combining these two functions, you can convert between any pair of bases: first parse the input string into a JavaScript number using the source base, then convert that number to a string in each target base.
Prefix Notation
Programming languages commonly use prefixes to distinguish bases in source code:
0b- binary, e.g.0b111111110o- octal, e.g.0o3770x- hexadecimal, e.g.0xFF
Decimal has no prefix because it is the default. This tool shows the appropriate prefix alongside each converted value so you can paste the result directly into your code.
Frequently Asked Questions
What is a number base (radix)?
A number base, also called a radix, is the number of unique digits used to represent values in a positional number system. Decimal uses 10 digits (0–9), binary uses 2 (0–1), octal uses 8 (0–7), and hexadecimal uses 16 (0–9 plus A–F). The base determines how each digit position contributes to the overall value - each position is worth baseposition times the digit.
Why do programmers use hexadecimal?
Hexadecimal is popular because each hex digit maps exactly to four binary bits, making it a compact and human-readable way to represent binary data. For example, the byte 11111111 in binary is simply FF in hex. It is widely used for memory addresses, colour codes (like #FF5733), Unicode code points, and low-level data inspection.
What are the 0b, 0o, and 0x prefixes in JavaScript?
JavaScript uses prefix notation to indicate number literals in different bases: 0b for binary (e.g., 0b1010 = 10), 0o for octal (e.g., 0o17 = 15), and 0x for hexadecimal (e.g., 0xFF = 255). Decimal numbers have no prefix. These prefixes let you write numeric constants directly in source code in the base that makes the most sense for the context.
What is the largest number this tool can convert?
This tool supports numbers up to JavaScript's maximum safe integer, which is 253 − 1 or 9,007,199,254,740,991. Beyond this value, JavaScript cannot represent integers exactly using its 64-bit floating-point format, so conversions may produce incorrect results. For most practical purposes - including 32-bit and 48-bit values - this limit is more than sufficient.