Developer Tools

Number Base Converter

Convert numbers between binary, decimal, hexadecimal, octal and any base from 2 to 36. Live conversion as you type, step-by-step explanation, bit viewer, and custom base support.

Last updated

Binary, Decimal, Hex, Octal
Any Base 2 to 36
Step-by-Step Explanation
Bit Viewer
Our networkLegalCost.usWhat will your legal case cost?Official formulas for all 50 states. Free, no signup.Check your state
01
Number Base Converter
Binary · Decimal · Hex · Octal · Any base 2 to 36
Decimal (Base 10)
255
255 decimal
Binary (Base 2)
11111111
1111 1111 (grouped nibbles)
Hexadecimal (Base 16)
FF
0xFF / #0000FF
Octal (Base 8)
377
0o377 (octal prefix)
Custom Base Conversion
Base Result
Range: Base 2 to 36 · Digits: 0 to 9, A-Z · Click result to copy
Binary Bit Viewer
1
7
1
6
1
5
1
4
1
3
1
2
1
1
1
0
Step-by-step Conversion ▼

How Base Conversion Works

To convert between bases, write the number as powers of the base: 255 is FF in hex (15 × 16 + 15), 11111111 in binary and 377 in octal. Type a number in any base from 2 to 36 above, including negatives, fractions such as 0.1 and whole numbers of any size, to see it in decimal, binary, hex, octal and a custom base, with the steps.

Every digit is worth its value times a power of the base. In hex, FF means 15 × 16 + 15 = 255; in binary, 11111111 means 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. To go the other way, divide by the new base again and again and read the remainders from the last to the first. The converter above does both, exactly, in your browser.

Decimal, Binary, Octal and Hex Reference

DecimalBinaryOctalHex
711177
81000108
10101012A
15111117F
16100002010
100110010014464
12711111111777F
1281000000020080
25511111111377FF
256100000000400100
1,000111110100017503E8
1,024100000000002000400
65,5351111111111111111177777FFFF
4,294,967,2951111111111111111111111111111111137777777777FFFFFFFF

One hex digit is exactly 4 bits and one octal digit exactly 3 bits, which is why programmers read binary in hex: 1111 1111 is F F.

Worked Examples

Hex 2F to decimal

2 × 16 + F (15) × 1 = 32 + 15 = 47.

Decimal 0.1 to binary

Multiply the fraction by 2 and keep the whole-number carry each time: 0.2 (0), 0.4 (0), 0.8 (0), 1.6 (1), then 0.6 gives 1.2 (1), 0.4 (0), 0.8 (0), 1.6 (1) and the pattern repeats. So 0.1 = 0.000110011001100... in binary, forever. Computers store a rounded version, which is why 0.1 + 0.2 prints as 0.30000000000000004 in JavaScript. The converter shows the first 32 digits and flags the result as repeating.

Negative numbers: −5 and −129

The plain answer is −101 in binary. Hardware stores it in two's complement: flip the bits of 5 (00000101 to 11111010) and add 1, giving 11111011 = 0xFB in 8 bits. −129 does not fit in 8 bits (the range is −128 to 127), so it needs 16: 1111111101111111 = 0xFF7F. The converter picks the smallest of 8, 16, 32, 64 bits and up.

Numbers past 253

Ordinary JavaScript numbers are exact only up to 9,007,199,254,740,991. Type 9007199254740993 into a converter that uses them and it silently becomes ...992. This converter uses BigInt, so 9,007,199,254,740,993 is exactly 0x20000000000001, and 264 = 18,446,744,073,709,551,616 is exactly 0x10000000000000000.

Common Mistakes

  • Prefixes: 0x, 0b and 0o only mark the base. Type 0xFF with base 16 selected, or just FF; the converter accepts both.
  • Base 32 is not Base32 encoding: here base 32 counts with 0 to 9 and A to V, so 255 is 7V. RFC 4648 Base32, used in authenticator app secrets, uses A to Z and 2 to 7 and encodes bytes, not numbers.
  • Leading zeros in code: in older JavaScript and in C, 010 means octal 8. Write 0o10 for octal and 10 for decimal to avoid surprises.
  • Letter case: ff, FF and Ff are the same hex value.
  • Two's complement width: 0xFB is −5 only if you read it as a signed 8-bit value; as an unsigned byte it is 251.

Base64, used to encode files and binary data as text, is a different thing from counting in base 64; for that use the Base64 encoder.

Method and sources. Positional notation: a digit d in position p is worth d × basep, with negative p after the point. Whole numbers are converted with JavaScript BigInt (exact at any size) and fractions by repeated multiplication with exact integer arithmetic, cut at 32 digits when they repeat. Two's complement follows the usual fixed-width definition (2n minus the magnitude). Data unit prefixes: NIST (SI prefixes) and IEC 80000-13 (KiB, MiB). Every value on this page was computed in Node.js.

Number Base Questions

A number base (or radix) defines how many unique digits a number system uses. Base 10 (decimal) uses digits 0 to 9 and is what humans use daily. Base 2 (binary) uses only 0 and 1. Computers use binary because electronic circuits have two stable states: off (0) and on (1), corresponding to low and high voltage. Every number, letter, image, and sound in a computer is ultimately stored as a sequence of 0s and 1s. Modern CPUs process 64-bit (64 binary digit) numbers in a single clock cycle. The number 255 in decimal is 11111111 in binary: 8 bits, or one byte.

Divide the decimal number by 2 repeatedly and record the remainders from bottom to top. Example: convert 42 to binary. 42 ÷ 2 = 21 remainder 0. 21 ÷ 2 = 10 remainder 1. 10 ÷ 2 = 5 remainder 0. 5 ÷ 2 = 2 remainder 1. 2 ÷ 2 = 1 remainder 0. 1 ÷ 2 = 0 remainder 1. Read remainders bottom to top: 101010. Verify: 32+8+2 = 42. This tool shows the exact division steps for any number. The "Step-by-step Conversion" section above walks through each division for the number you enter.

Hexadecimal (base 16) uses digits 0 to 9 and letters A-F (where A=10, B=11, C=12, D=13, E=14, F=15). Programmers use hex because one hex digit represents exactly 4 binary bits (a nibble), and two hex digits represent one byte (8 bits). This makes it very compact for representing binary data. Examples: the color #FF5733 is three bytes (R=255, G=87, B=51). Memory addresses like 0x7FFE4000 are easier to read than binary. The prefix 0x indicates hex in most programming languages. 256 bytes = 0x100 in hex = 100000000 in binary.

A bit is a single binary digit (0 or 1). A nibble is 4 bits. A byte is 8 bits and can represent values 0 to 255. In SI units, a kilobyte (kB) is 1,000 bytes, a megabyte (MB) 1,000,000 bytes, a gigabyte (GB) 10^9 bytes and a terabyte (TB) 10^12 bytes. The binary units are the kibibyte (KiB), 1,024 bytes (2^10), the mebibyte (MiB), 1,048,576 bytes, the gibibyte (GiB) and the tebibyte (TiB). Drive makers use SI units, while Windows counts in binary units but labels them KB, MB and GB, which is why a 1 TB drive shows as about 931 GB.

One octal digit represents exactly 3 binary bits. This made octal popular in early computing when 12-bit, 24-bit, and 36-bit word sizes were common (all divisible by 3). Today octal is mainly used for Unix/Linux file permissions. The chmod 755 command uses octal: 7 = 111 (read+write+execute), 5 = 101 (read+execute). The three digits represent Owner, Group, and Others permissions. chmod 644 = Owner read+write (110=6), Group read-only (100=4), Others read-only (100=4). chmod 777 gives full permissions to everyone. Octal is also used in some network protocols and escape sequences (\077 in C).

Two's complement is the standard way computers represent negative integers in binary. To negate a number: flip all bits (one's complement), then add 1. Example: +5 in 8-bit binary = 00000101. Flip bits: 11111010. Add 1: 11111011 = -5. In an 8-bit signed integer, the range is -128 to +127. The most significant bit (leftmost) is the sign bit: 0 = positive, 1 = negative. Two's complement is elegant because addition and subtraction use the same hardware circuit regardless of sign. 5 + (-5) = 00000101 + 11111011 = 100000000 (the overflow bit is discarded) = 0. This converter accepts negative numbers and, for whole negatives, also shows the two's complement form in the smallest fitting width (8, 16, 32, 64 bits and up).

Base 36 uses digits 0 to 9 and letters A-Z (case-insensitive), giving 36 possible digits. It is used for compact human-readable identifiers, URL shorteners, and some UUID implementations. This converter supports Base 36. Base 64 is different: it uses 0 to 9, A-Z, a-z, +, and / (64 symbols total) and is used specifically for encoding binary data (images, files) as ASCII text in emails and web contexts (data URIs). The Base64 standard (data:image/png;base64,...) is not the same as counting in base 64; it is an encoding scheme. This converter supports mathematical base conversion up to Base 36 (the maximum using standard alphanumeric digits).

Key hex values: 0xFF = 255 (max unsigned byte, all bits set). 0x00 = 0. 0x80 = 128 (most significant bit set in a byte). 0xDEADBEEF = a classic placeholder/debug value. 0xCAFEBABE = Java class file magic number. 0x7FFFFFFF = 2,147,483,647 (max positive 32-bit signed int). 0xFFFFFFFF = 4,294,967,295 (max unsigned 32-bit int). 0x00000000 = null pointer. #FFFFFF = white in CSS. #000000 = black. #FF0000 = pure red. Memory addresses on 64-bit systems are 16 hex digits long (e.g., 0x00007FFF5FBFF888).

A CSS hex color like #A3B4C5 is three bytes: R=A3, G=B4, B=C5. Convert each byte from hex to decimal: A3 = 10×16+3 = 163. B4 = 11×16+4 = 180. C5 = 12×16+5 = 197. So #A3B4C5 = rgb(163, 180, 197). Short hex colors like #FFF expand to #FFFFFF (each digit is doubled). Use this converter: enter A3 in the input, set base 16, read the decimal result = 163. Repeat for B4 and C5. Alternatively, parseInt("A3", 16) in JavaScript returns 163 directly.

Bitwise operations work on individual bits of integers. AND (&): both bits must be 1. OR (|): either bit is 1. XOR (^): bits are different. NOT (~): flips all bits. Left shift (<<): multiplies by 2 per shift. Right shift (>>): divides by 2 per shift. Common uses: n & 1 checks if n is odd (last bit). n & (n-1) clears the lowest set bit (checks if n is a power of 2 when result is 0). 1 << n computes 2^n efficiently. x | 0x20 converts an uppercase ASCII letter to lowercase (sets bit 5). Bitwise ops are critical in networking (IP masking), cryptography, graphics, and embedded systems.

A fraction ends in a base only if its denominator divides a power of that base. 0.1 is 1/10, and 10 has the factor 5, which no power of 2 contains, so in binary it repeats forever: 0.000110011001100... The same happens with 1/3 in decimal (0.333...). Fractions like 0.5, 0.25 and 0.375 end, because their denominators are powers of 2: 0.375 = 0.011 in binary.

Whole numbers of any length: they are converted with BigInt, so there is no 253 limit and a 100-digit decimal number converts exactly. Fractions are exact up to 32 digits after the point; longer repeating results are cut there and marked. The bit viewer is shown for values up to 256 bits, and the step-by-step list shows the first 64 steps.