Number Base Converter

Convert numbers between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). Edit any field and all others update instantly. Everything runs in your browser — nothing is sent to any server.

0b
0o
0x

Quick reference

Binary
Octal
Decimal
Hex

Click any value to load it

Related Tools

Frequently Asked Questions

Why do programmers use hexadecimal instead of just decimal?

Hexadecimal (base 16) is convenient because each hex digit represents exactly 4 bits (a nibble), and two hex digits represent exactly one byte. This makes binary data much more readable: the byte 11111111 is just FF in hex, and you can split it visually into nibbles (F=1111, F=1111). Memory addresses, color values (#FF5733), file signatures (magic bytes), and bitmasked flags are all much easier to read and write in hex than in decimal or binary.

How does binary represent negative numbers?

There are multiple representations. Sign-magnitude uses the leftmost bit as a sign flag (0=positive, 1=negative), but it has two zeros (+0 and -0). Two's complement is the universal standard used by modern CPUs: to negate a number, flip all bits and add 1. In an 8-bit two's complement system, -1 is 11111111 (255 unsigned), -128 is 10000000, and the range is -128 to +127. This converter works with unsigned integers — for signed/two's complement interpretation, the decimal value you enter must be non-negative.

What is the difference between octal and hex, and when is octal used?

Both are power-of-2 bases, but octal (base 8) uses digits 0–7 and each octal digit represents 3 bits, while hex (base 16) uses 0–9 and A–F with each digit representing 4 bits. Hex is more widely used today. Octal's main use is Linux file permissions: chmod 755 is octal notation, where each digit represents 3 permission bits (read=4, write=2, execute=1). Octal also appears in C/C++ literals (leading zero: 0755) and some older UNIX tools.

How do I convert a hex color code to RGB values?

A hex color like #FF5733 has three 2-digit hex pairs: FF (red), 57 (green), 33 (blue). Convert each pair from hex to decimal: FF=255, 57=87, 33=51. So #FF5733 = rgb(255, 87, 51). You can use this converter to convert each channel individually: enter FF in the hex field to get decimal 255 for the red channel. For the full color conversion workflow, try our Color Converter tool which handles the complete #RRGGBB format.

What happens when a number is too large to convert accurately?

JavaScript uses 64-bit floating-point (IEEE 754) for all numbers, which can only represent integers exactly up to 2^53 - 1 (Number.MAX_SAFE_INTEGER = 9,007,199,254,740,991). Numbers larger than this may lose precision — the conversion appears to work but the result may be off by 1 or more. For large numbers (like 64-bit integers or cryptographic hashes), you'd need BigInt support, which this converter currently shows a warning for but does not implement.