Number Base Converter
Convert numbers between binary, octal, decimal, and hexadecimal. All bases shown simultaneously.
2550xFF0b111111110o377What is Number Base Conversion?
Computers store all data as binary (base 2), but programmers frequently need to read and write numbers in other bases — decimal (base 10) for everyday math, hexadecimal (base 16) for memory addresses and colors, and octal (base 8) for Unix file permissions.
Decimal (base 10) uses digits 0–9 and is what we use in everyday life. Binary (base 2) uses only 0 and 1 — the native language of computer hardware. Hexadecimal (base 16) uses 0–9 and A–F; each hex digit represents exactly 4 bits, making it a compact way to read binary values. Octal (base 8) uses 0–7; each octal digit represents 3 bits and is commonly used for Unix permission masks.
For example, the decimal value 255 is 0xFF in hex, 0b11111111 in binary, and 0377 in octal. All four represent the same value — the base just determines how it is written.
Quick Reference
| Decimal | Hex | Binary | Octal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 8 | 8 | 1000 | 10 |
| 10 | A | 1010 | 12 |
| 15 | F | 1111 | 17 |
| 16 | 10 | 10000 | 20 |
| 32 | 20 | 100000 | 40 |
| 64 | 40 | 1000000 | 100 |
| 128 | 80 | 10000000 | 200 |
| 255 | FF | 11111111 | 377 |
| 256 | 100 | 100000000 | 400 |
Number Bases in Code
| Base | JavaScript | Python | Go |
|---|---|---|---|
| Decimal | 255 | 255 | 255 |
| Hex | 0xFF | 0xFF | 0xFF |
| Binary | 0b11111111 | 0b11111111 | 0b11111111 |
| Octal | 0o377 | 0o377 | 0377 |
Where Base Conversion Comes Up
- ▸Reading a chmod permission code — Convert 755 (octal) to binary (111 101 101) to see exactly which read/write/execute bits are set for owner, group and others.
- ▸Debugging a color or memory address — Convert a hex color like 0x3B82F6 or a memory address to decimal to do arithmetic on it, or back again to match documentation.
- ▸Working with bit flags — Convert a decimal flags value to binary to see which individual bits are set in a permissions or feature-flag bitmask.
- ▸Translating between a spec and your code — A protocol doc might list values in hex while your code logs them in decimal — convert between the two to confirm they match.