Skip to main content
CodeLint.Dev Dev Tools

Number Base Converter — Binary, Octal, Hex & Any Base

Convert between binary, octal, decimal, hexadecimal and any base from 2 to 36, with arbitrary precision for values beyond 64 bits.

Examples
step
Binary base 2 0b
0010 1010
Octal base 8 0o
Decimal base 10
Hex base 16 0x
#00002A web color
Roman I–MMMCMXCIX
= XLII
Bit Width
Number Bases
Binary (2) — digits 0–1. Each position doubles. Native to digital hardware.
Octal (8) — digits 0–7. Exactly 3 binary bits per digit. Unix file permissions.
Decimal (10) — everyday counting, digits 0–9.
Hex (16) — digits 0–9 and A–F. Exactly 4 binary bits (one nibble) per digit.
Roman — additive notation, range 1–3999 (I–MMMCMXCIX).
Bit Width Guide
8-bit — 0 to 255 — uint8, byte, ASCII
16-bit — 0 to 65,535 — uint16, short
32-bit — 0 to 4,294,967,295 — uint32, int
64-bit — 0 to 18,446,744,073,709,551,615 — uint64
Two's Complement CPU native

How CPUs store negative integers. To negate: flip all bits (one's complement) then add 1. -1 in 8-bit = 11111111 (0xFF). Type a negative number and enable the toggle above.

Hex Color Codes

Web colors are 24-bit hex: #RRGGBB. If your decimal value is 0–16,777,215 a live color swatch appears on the Hex panel. Try (pure red, #FF0000).

The bases you actually meet

BaseDigitsPrefixWhere
2 — binary0–10bBit flags, permissions, network masks
8 — octal0–70o or leading 0Unix file permissions (chmod 755)
10 — decimal0–9noneEverything else
16 — hex0–9, A–F0x or #Colours, memory addresses, hashes, byte dumps
320–9, A–VnoneBase32 encoding, TOTP secrets
360–9, A–ZnoneShort IDs — the densest base using only alphanumerics

A leading zero means octal in C, Java and older JavaScript — so 010 is 8, not 10. This is why modern languages prefer the explicit 0o prefix and why JSON forbids leading zeros entirely.

Why hexadecimal is everywhere

Hex is not arbitrary convention — it maps exactly onto how computers group bits.

One hex digit represents exactly four bits, because 16 = 2⁴. So two hex digits are exactly one byte, and there is no arithmetic involved in the conversion: 0xFF is 11111111, 0xA3 is 10100011. You can convert by looking at four bits at a time, in either direction, without carrying.

That alignment is what makes hex readable where binary is not. A 256-bit hash is 64 hex characters, which fits on a line; the same value in binary is 256 characters and completely unreadable. A memory address, a colour, a MAC address, a UUID — all are byte sequences, and hex is the shortest notation that keeps byte boundaries visible.

Octal has the same property with three bits per digit, which is why Unix permissions use it: read, write and execute are exactly three bits, so one octal digit describes one permission set. chmod 755 is three groups of three bits — 111 101 101 — for owner, group and other.

Converting in code

JavaScript
// To a string in any base from 2 to 36
(255).toString(2);    // '11111111'
(255).toString(16);   // 'ff'
(255).toString(36);   // '73'

// From a string — ALWAYS pass the radix
parseInt('ff', 16);   // 255
parseInt('0755', 8);  // 493

// Omitting the radix is a classic bug source; pass it always.
// parseInt also stops at the first invalid character rather
// than failing, so parseInt('12abc') returns 12, silently.
Number('0xff');       // 255, and rejects trailing junk
Beyond 2^53 — use BigInt
// Numbers lose integer precision above 2^53 - 1
Number.MAX_SAFE_INTEGER;        // 9007199254740991

// BigInt is exact at any size
BigInt('0xffffffffffffffff').toString(10);
// '18446744073709551615'

(2n ** 128n).toString(16);
Python — arbitrary precision by default
int('ff', 16)      # 255
int('0b1010', 0)   # 10 — base 0 infers from the prefix

bin(255)           # '0b11111111'
oct(255)           # '0o377'
hex(255)           # '0xff'

f'{255:08b}'       # '11111111' — zero-padded, no prefix
f'{255:#06x}'      # '0x00ff'

About

The Number Base Converter translates any integer simultaneously across five number systems: binary (base 2), octal (base 8), decimal (base 10), hexadecimal (base 16), and Roman numerals. All five representations update in real time as you type in any field — no submit button, no direction lock. Roman numeral input and output supports the full classical range I–MMMCMXCIX (1–3999), and only canonical forms are accepted, so IIII is correctly rejected in favour of IV. A live bit-pattern visualizer shows each bit as a lit or dim cell, grouped into nibbles (4 bits, one hex digit) and bytes. Select 8, 16, 32, or 64-bit width, enable Two's Complement to see how CPUs encode negative integers, and watch the cells update instantly. When the decimal value fits in 24 bits the hex panel shows a live colour swatch — ideal for CSS and design work. Quick-step buttons (+1, −1, ×2, ÷2) let you navigate values without retyping. All logic runs in your browser using JavaScript's native BigInt — no external libraries, no server, no data collection.

How to use

  1. 1 Type a number into any field (binary, octal, decimal, hex, or Roman) and all other fields update immediately.
  2. 2 Enter a Roman numeral such as XLII or MMXXIV in the pink Roman panel — the tool validates canonical form and converts.
  3. 3 Use the example pills in the toolbar to quickly load preset values like 42, 255, or 65535.
  4. 4 Click the step buttons (+1, −1, ×2, ÷2) to walk through values without retyping.
  5. 5 Select a bit width (8, 16, 32, or 64) in the bit visualizer to inspect the binary layout; enable Two's Complement for negative numbers.
  6. 6 Enter a number from 0 to 16,777,215 and look at the hex panel for a live colour swatch.
  7. 7 Click the copy icon next to any panel to copy that representation to your clipboard.
Can I type directly into any field, including Roman numerals?
Yes — all five fields are live inputs. Edit binary and hex updates. Edit the Roman panel and all number-base fields update. The only constraint on Roman input is that it must be a valid canonical form (I, IV, V, IX, X, XL, L, XC, C, CD, D, CM, M combinations) in the range 1–3999.
Why does my Roman numeral get rejected?
The tool only accepts canonically correct Roman numerals. For example, IIII is not accepted — the canonical form is IV. Similarly, VV is invalid (use X), and MMMM is invalid (3999 = MMMCMXCIX is the maximum). The validation round-trips: it converts your input to decimal and back to Roman, then checks that the result matches your input exactly.
What is the range for Roman numeral conversion?
Standard Roman numerals cover 1 to 3999 (MMMCMXCIX). Zero and negative numbers have no Roman representation and the Roman panel shows "Out of range". Numbers 4000 and above also exceed the classical system.
What does the bit visualizer show for numbers larger than the selected width?
If the value requires more bits than the selected width (for example, 256 in an 8-bit view), an overflow warning appears and the value is shown truncated to the selected width — just like an integer overflow in a CPU register.
How does the hex colour preview work?
Web colours are 24-bit RGB values in the range 0–16,777,215 (0x000000–0xFFFFFF). If the current number fits in 24 bits, the hex panel shows a small colour swatch and the CSS hex code. Try typing 16711680 (0xFF0000, pure red) or 65535 (0x00FFFF, cyan).
Is my data sent to a server?
No. All conversion, validation, and visualization runs entirely in your browser using JavaScript's native BigInt. No external libraries are loaded and no network requests are made — your numbers never leave your device.