๐ข Number Base Converter
Convert between binary, octal, decimal, and hexadecimal instantly.
Ever stared at a string of 0s and 1s and wondered what number it actually represents? Or needed to turn a decimal like 255 into the hex FF for a CSS color code? Our Number Base Converter translates between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) in both directions โ instantly, right in your browser.
For example, you are setting a color in CSS and the design calls for pure red. The hex value is FF0000, but your design tool reports the red channel as the decimal 255. Type 255 into the converter, set “From” to Decimal and “To” to Hexadecimal, and you will see 255 = FF in a fraction of a second. No mental math, no lookup tables.
This tool is invaluable for developers, students, and anyone working with low-level systems. Programmers use it constantly when reading memory addresses, writing bitmasks, or debugging network packets. Students encounter binary and hex in computer science and digital electronics courses. And hobbyists tinkering with microcontrollers, RGB LEDs, or file formats will find it indispensable for translating between the number systems that hardware actually speaks.
Because everything runs locally in your browser, your values never leave your device, and the converter works even on a slow or offline connection. Bookmark it for your next coding session, exam, or electronics project.
How the number base conversion works
Every number system works the same way: a base determines how many digits are available and how the value grows as you move left. Our converter supports the four most common bases:
- Binary (base 2) uses only
0and1. Each position is a power of 2 (1, 2, 4, 8, 16, 32, 64, 128, …). This is the native language of computers. - Octal (base 8) uses digits
0โ7. Each position is a power of 8. It was historically popular in computing because each octal digit maps cleanly to three binary bits. - Decimal (base 10) uses digits
0โ9. Each position is a power of 10. This is the everyday system humans use. - Hexadecimal (base 16) uses digits
0โ9and lettersAโF. Each position is a power of 16. It is the standard for representing memory addresses, color codes, and binary data in a compact form, because each hex digit maps exactly to four binary bits.
The conversion logic is straightforward. The tool first parses your input in the “From” base using parseInt(value, fromBase), which converts it to a plain decimal integer internally. Then it formats that integer in the “To” base using JavaScript’s toString(toBase). Because both steps use the language’s built-in, exact integer arithmetic, the result is always precise โ there is no floating-point rounding to worry about.
Worked example: Convert 255 (decimal) to hexadecimal. 255 รท 16 = 15 remainder 15. In hex, 15 is written as F, so 255 = FF. The converter does this instantly: 255 = FF.
Worked example: Convert the binary 1010 to decimal. Reading right to left: 0ร1 + 1ร2 + 0ร4 + 1ร8 = 2 + 8 = 10. So 1010 (binary) = 10 (decimal) = A (hex) = 12 (octal).
Practical examples with real data
Here are a few conversions you can check by hand to build confidence in the tool:
| Decimal | Binary | Octal | Hexadecimal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 64 | 1000000 | 100 | 40 |
| 255 | 11111111 | 377 | FF |
| 1024 | 10000000000 | 2000 | 400 |
A couple worth noting: 255 is the maximum value of a single byte (8 bits), which is why it shows up everywhere โ as FF in hex color codes, as 255 in RGB channels, and as 11111111 in binary. And 1024 is a power of 2 (2ยนโฐ), which is why it appears as a clean 10000000000 in binary but a round 400 in hex.
Edge cases and rounding
- Negative numbers: The converter accepts negative integers and returns them in the target base with a leading minus sign (for example,
-255in decimal becomes-FFin hex). It does not produce two’s-complement or unsigned representations. - Fractional values: This tool converts whole numbers only. If you enter a value with a decimal point, the fractional part is ignored. For fractional binary or hex conversions you would need a separate tool.
- Prefixes: The converter accepts common prefixes โ
0xfor hex,0bfor binary, and0ofor octal โ and strips them automatically. So you can paste0xFFor0b1010directly and get the right answer. - Case-insensitive hex: In hexadecimal input, both uppercase (
FF) and lowercase (ff) letters are accepted and normalized. - Very large numbers: Because the tool uses JavaScript’s native integer handling, it can convert numbers far beyond what you will typically need โ up to the safe integer range (about 9 quadrillion). Beyond that, results may lose precision, which is rarely a concern in practice.
- Invalid input: If you type a digit that does not belong to the selected base (for example, a
2in binary or aGin hex), the converter shows a clear error message instead of a wrong answer.
Frequently Asked Questions
Frequently Asked Questions
How do I convert decimal to binary with this tool?
Enter the decimal number, set "From" to Decimal (base 10), and choose "To" as Binary (base 2). The result appears instantly. For example, 255 in decimal becomes 11111111 in binary.
What number bases are supported?
This converter supports the four most common bases: binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). You can convert between any pair of these in either direction.
Why is hexadecimal used in computing?
Hexadecimal is compact and maps cleanly to binary: each hex digit represents exactly four binary bits. That makes it ideal for representing memory addresses, color codes (like #FF0000), and raw binary data in a readable form. One byte (8 bits) is always exactly two hex digits.
How do I convert a hex color code to RGB values?
A hex color like #FF0000 is made of three two-digit hex pairs: red (FF), green (00), and blue (00). Convert each pair to decimal using this tool โ FF = 255, 00 = 0 โ to get the RGB values (255, 0, 0).
Does this converter work offline?
Yes. Once the page has loaded, all conversion logic runs client-side in your browser. No server requests are made, so you can keep using the converter even if your internet connection drops.
Can I convert negative numbers?
Yes. The converter accepts negative integers and returns them with a leading minus sign in the target base (for example, -255 becomes -FF in hex). It does not produce two's-complement or unsigned representations.
What is the largest number I can convert?
The converter handles any whole number up to JavaScript's safe integer range (about 9 quadrillion). Beyond that, results may lose precision, but this is rarely a concern for real-world programming, electronics, or study use.
Why is 255 written as FF in hexadecimal?
255 รท 16 = 15 with a remainder of 15. In hex, 15 is represented by the letter F, so 255 = FF. This is also the maximum value of a single byte, which is why FF appears so often in color codes and low-level programming.
๐ Try other converters:
๐พ Data ๐๏ธ Roman Numerals ๐งพ JSON to CSV ๐ Excel to CSV ๐ผ๏ธ Image Resizer ๐ PDF to Word ๐ธ PDF to JPG ๐ Word to PDFAbout the author
This converter is maintained by Aren Breur, the editor of ConvertAny.app. Aren builds fast, free browser-based tools that make everyday conversions simple without sign-ups or data collection. If you have feedback or a converter you would like added, reach out via the contact page or email aren2connect@gmail.com.