DeveloperApril 2026 ยท 6 min read

How to Convert Between Binary, Octal, Decimal, and Hex

Number base conversion is fundamental to computing. Computers operate in binary (base-2), file permissions use octal (base-8), humans think in decimal (base-10), and colors and memory addresses use hexadecimal (base-16). Converting between these bases is a core skill for developers.

๐Ÿ”ข
Try the Number Base Converter
Free, no signup
โ†’
DG
Derek Giordano
Designer & Developer
In this guide
01Understanding Number Bases02Binary โ†” Decimal03Hexadecimal Conversions04Converting in JavaScript
โšก Key Takeaways
  • Convert numbers between binary (base-2), octal (base-8), decimal (base-10), and hexadecimal (base-16).
  • Covers understanding number bases.
  • Covers binary โ†” decimal.
  • Covers hexadecimal conversions.
  • Covers converting in javascript.

Understanding Number Bases

A number base defines how many digits are available. Decimal uses 0-9 (10 digits). Binary uses 0-1 (2 digits). Octal uses 0-7 (8 digits). Hexadecimal uses 0-9 and A-F (16 digits). The number 255 in decimal equals 11111111 in binary, 377 in octal, and FF in hexadecimal โ€” they all represent the same quantity.

Binary โ†” Decimal

To convert binary to decimal, multiply each digit by its positional power of 2 and sum: 1101 = (1ร—8) + (1ร—4) + (0ร—2) + (1ร—1) = 13. To convert decimal to binary, repeatedly divide by 2 and read remainders bottom-to-top: 13 รท 2 = 6 remainder 1, 6 รท 2 = 3 remainder 0, 3 รท 2 = 1 remainder 1, 1 รท 2 = 0 remainder 1. Result: 1101.

๐Ÿ’ก Tip
Use 3+ color stops instead of 2 to avoid the muddy gray band that appears in the center of complementary-color gradients.

Hexadecimal Conversions

Hex is the most practical base for developers โ€” it maps cleanly to binary (each hex digit = 4 binary digits) and is used for colors (#FF6B6B), memory addresses, and byte values. F = 1111 in binary = 15 in decimal. FF = 11111111 = 255. A0 = 10100000 = 160. The Number Base Converter handles all conversions instantly โ€” enter any value in any base and see all other bases.

โš  Warning
CSS gradients used as backgrounds cannot be animated with standard transitions. Use background-size animation or @property registered custom properties instead.

Converting in JavaScript

parseInt('FF', 16) converts hex to decimal (255). parseInt('11111111', 2) converts binary to decimal (255). (255).toString(16) converts decimal to hex ('ff'). (255).toString(2) converts decimal to binary ('11111111'). The second argument specifies the base (radix).

Frequently Asked Questions

How do I convert binary to decimal?+
Multiply each binary digit by its positional power of 2 (right to left: 1, 2, 4, 8, 16...) and sum the results. Or use the Number Base Converter for instant conversion.
Why do programmers use hexadecimal?+
Hex maps cleanly to binary (1 hex digit = 4 bits), making it compact and easy to convert. It's used for colors (FF = 255 = max channel), memory addresses, and byte values.
What is octal used for?+
Octal is primarily used for Unix file permissions (chmod). Each permission set (read+write+execute) maps to a single octal digit: 7 = rwx, 5 = r-x, 4 = r--.
Try it yourself

Use the Number Base Converter โ€” free, no signup required.

โšก Open Number Base Converter
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.