Skip to main content
The Number Base Converter converts numeric values between different bases (radixes): binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). It supports arbitrary precision using JavaScript’s BigInt for large numbers.

Use Cases

  • Programming and debugging - Convert between hex, decimal, and binary
  • Network engineering - Convert IP addresses and subnet masks
  • Color codes - Convert hex color codes to RGB decimal values
  • Bit manipulation - Work with binary representations
  • Memory addresses - Convert between hex and decimal addresses
  • Low-level programming - Octal file permissions, bitmasks

How It Works

The tool accepts a number in any base (2-36) and displays its equivalent in binary, octal, decimal, and hexadecimal:
  1. Input format: value|base (e.g., FF|16 for hex, 1010|2 for binary)
  2. Default base: If no base is specified, assumes decimal (base 10)
  3. Output: Shows conversions to binary, octal, decimal, and hex
The tool uses BigInt for arbitrary precision, so it can handle very large numbers (thousands of digits) without loss of precision.

Input Format

Format: number|base
  • number: The numeric value (using digits valid for the specified base)
  • base: The base/radix (2-36)
  • If base is omitted, assumes base 10

Valid Digit Ranges by Base

BaseValid DigitsExample
2 (Binary)0-11010
8 (Octal)0-7755
10 (Decimal)0-9255
16 (Hex)0-9, A-FFF (case-insensitive)
36 (Max)0-9, A-ZZ = 35

Output Format

Always shows four representations:
Binary:  11111111
Octal:   377
Decimal: 255
Hex:     FF

Examples

Input:
FF|16

Output:
Binary:  11111111
Octal:   377
Decimal: 255
Hex:     FF

Technical Details

Located in lib/tools/engine.ts:506-518
The tool implements a custom base parser using BigInt for arbitrary precision:
function parseBase(value: string, base: number): bigint {
  let acc = 0n;
  for (const ch of value.toLowerCase()) {
    const digit = /* convert char to digit value */;
    acc = acc * BigInt(base) + BigInt(digit);
  }
  return acc;
}

Supported Bases

  • Range: 2 to 36
  • Digits:
    • 0-9: Values 0-9
    • A-Z: Values 10-35 (case-insensitive)

Negative Numbers

Negative numbers are supported:
Input: -10|10
Output:
Binary:  -00001010
Decimal: -10
Hex:     -A

Binary Padding

Binary output is padded to 8 bits (1 byte) minimum:
Input: 5
Binary:  00000101  (padded to 8 bits)

Common Use Cases

RGB Color Codes

Convert hex color codes to decimal RGB values:
Hex: #FF5733 → Split into FF, 57, 33

FF|16 → 255 (Red)
57|16 → 87  (Green)
33|16 → 51  (Blue)

RGB: rgb(255, 87, 51)

Unix File Permissions

Convert octal permissions to binary/decimal:
755|8 → Decimal 493 → Binary 111101101

7 (owner)   = 111 = rwx (read, write, execute)
5 (group)   = 101 = r-x (read, execute)
5 (others)  = 101 = r-x (read, execute)

Memory Addresses (Hex to Decimal)

0x1A2B|16 → Decimal 6699

Subnet Masks

Convert CIDR notation to binary:
255.255.255.0 = /24

255|10 → Binary 11111111
0|10   → Binary 00000000

Full mask: 11111111.11111111.11111111.00000000

Advanced Examples

Input:
ZZ|36

Output:
Binary:  10010010001
Octal:   2221
Decimal: 1295
Hex:     50F

Note: Base 36 uses 0-9 and A-Z (Z=35)

Error Handling

If you enter a digit that’s invalid for the specified base (e.g., 9 in base 8, or G in base 16), you’ll get an error: “Invalid digit ‘X’ for base Y.”

Common Errors

ErrorCauseFix
Invalid digit ‘2’ for base 2Used digit outside base rangeUse only 0-1 for binary
Invalid digit ‘G’ for base 16Hex only uses 0-FUse A-F (G is invalid)
Base must be between 2 and 36Invalid base specifiedUse base 2-36

Tips and Tricks

Quick Hex to Decimal

FF|16 = 255
100|16 = 256
1000|16 = 4096

Powers of 2 (Binary)

1|2      = 1
10|2     = 2
100|2    = 4
1000|2   = 8
10000|2  = 16
100000|2 = 32

Octal Shortcuts

10|8  = 8
100|8 = 64
777|8 = 511

Build docs developers (and LLMs) love