Number Base Converter: Binary, Decimal, Hex
A number base converter changes a number from one numeral system to another. The value stays the same, but the representation changes.
For example, these all represent the same value:
Decimal: 255
Binary: 11111111
Hexadecimal: FF
Octal: 377Use the Number Base Converter when working with binary flags, color channels, permissions, low-level data, hashes, IDs, or programming examples.
What Is a Number Base?
A number base defines how many digits are available before a position carries into the next column.
Decimal is base 10. It uses ten digits:
0 1 2 3 4 5 6 7 8 9Binary is base 2. It uses two digits:
0 1Hexadecimal is base 16. It uses sixteen symbols:
0 1 2 3 4 5 6 7 8 9 A B C D E FOctal is base 8. It uses:
0 1 2 3 4 5 6 7Why Binary Matters
Computers store data using binary states. A bit is either 0 or 1. Larger values are built by grouping bits together.
For example:
8-bit binary: 11111111
Decimal: 255Binary is useful when you need to inspect flags, masks, permissions, or bit-level behavior.
Common Bases at a Glance
| Base | Digits | Common use |
|---|---|---|
| Base 2 | 0-1 | Bits, flags, masks |
| Base 8 | 0-7 | Unix-style permissions, some legacy formats |
| Base 10 | 0-9 | Human-readable numbers |
| Base 16 | 0-9, A-F | Bytes, colors, hashes, memory, debugging |
The value may be the same, but the representation should fit the task. Developers often use hexadecimal because it is much shorter than binary while still mapping cleanly to bytes.
Why Hexadecimal Is Common
Hexadecimal is compact and maps neatly to binary. One hex digit represents four binary bits.
For example:
1111 1111 = FFThat is why hex appears in color values, memory addresses, byte dumps, hashes, and encoded data.
In CSS color notation:
#FF0000FF means the red channel is at its maximum value.
Hex and Bytes
A byte contains 8 bits. Two hex digits represent one byte:
Binary: 1111 1111
Hex: F F
Decimal: 255This is why byte values are often written from 00 to FF. You see this pattern in color channels, binary file viewers, cryptographic hashes, and network debugging.
For CSS colors, each pair of hex digits is one channel:
#3366FF
33 = red
66 = green
FF = blueUse the Color Converter when the number represents a color rather than a general-purpose numeric value.
Decimal Is Still the Human-Friendly Base
Decimal is easiest for everyday reading because it is the system most people learn first. When debugging technical values, it is common to convert binary or hex back to decimal to confirm the actual numeric value.
Prefixes and Notation in Code
Programming languages often use prefixes to show the base:
0b11111111 binary
0o377 octal
0xFF hexadecimal
255 decimalThese prefixes are not part of the mathematical value. They tell the reader or parser how to interpret the digits that follow.
When writing documentation, include the base label or prefix so values are not misread.
Signed Values and Fixed Width
Base conversion is straightforward for non-negative values, but signed integers need context. The same binary pattern can represent a different value depending on bit width and interpretation.
For example, 11111111 can mean:
255as an unsigned 8-bit value-1in many signed 8-bit two’s complement contexts
A general converter can show representation changes, but low-level debugging may also require knowing whether the value is signed, how many bits are used, and how the system stores negative numbers.
Bits, Bytes, and Grouping
Binary values become easier to read when grouped:
11111111
1111 1111Each group of four bits maps to one hexadecimal digit:
1111 = F
1111 1111 = FFThis relationship is why developers often convert binary to hexadecimal when inspecting bytes, masks, colors, or encoded values.
Common Conversion Mistakes
Do not confuse a representation with a different value. 10 in binary equals 2 in decimal. 10 in decimal equals 10.
Do not ignore prefixes. In code, 0xFF usually means hexadecimal, while 0b11111111 usually means binary.
Do not assume every long string of letters and numbers is a number. Hashes and IDs may contain hexadecimal-looking characters, but converting them as a normal number may not be useful.
Do not ignore leading zeros when the value represents fixed-width data. 00001111 and 1111 have the same numeric value, but the leading zeros may matter when showing an 8-bit byte.
Real-World Examples
Unix permissions
755is often read as octal permissions: owner can read/write/execute, group can read/execute, and others can read/execute.
Bit flags
0b00000101can indicate that two flags are enabled: bit 0 and bit 2.
Color channels
#00FF00uses hex pairs to represent red, green, and blue channel values.
Hashes
Hash strings often look hexadecimal, but they are usually identifiers or digests. Converting a whole hash to decimal rarely helps. Inspecting bytes or comparing strings is usually more useful.
A Practical Workflow
- Identify the source base.
- Convert the value with the Number Base Converter.
- Use the Color Converter for CSS color-specific conversions.
- Use the Hash Generator if the value is a digest rather than a normal number.
- Document the base in examples so readers do not misread the value.
Debugging Checklist
Before converting a value, ask:
- What base is the input written in?
- Is there a prefix such as
0x,0b, or0o? - Does leading zero padding matter?
- Is the value signed or unsigned?
- Is the value a number, a color, a permission, a flag, or a hash?
- Does the target system expect uppercase or lowercase hex?
The answers affect how the converted value should be interpreted.
Final Tip
Number base conversion is mostly about context. The same characters can mean different values depending on the base. Always label examples clearly when writing docs, debugging code, or sharing technical notes.
Keep going