How to convert between number bases
- 1Choose the Input base: Binary (2), Octal (8), Decimal (10) or Hexadecimal (16).
- 2Type your number into the Value field. A matching prefix like 0x, 0b or 0o is optional, or click Load Sample to start with 255.
- 3Read the binary, octal, decimal and hexadecimal results, which update as you type. If a character isn't valid for the selected base, the field tells you.
- 4Click the copy icon next to any result. It copies the digits without the 0b, 0o or 0x prefix.
Why developers work in different bases
A number base, or radix, is how many distinct digits a positional system uses. In decimal, each position is worth ten times the one to its right. In binary it's two, in octal eight, and in hexadecimal sixteen, with the letters a to f standing for 10 to 15. The value doesn't change between bases, only the way it's written: 255, 0xff, 0o377 and 0b11111111 are the same number.
Binary is the language of bits, so it's what you reach for when reading bit flags, masks and protocol headers. Hex is the compact way to write those same bits, because each hex digit maps to exactly four bits and two hex digits make one byte. That makes binary to hex a matter of grouping: split the bits into fours from the right and replace each group with one hex digit. That's why memory addresses, byte dumps, hashes, UUIDs and CSS colors like #ff8800 are written in hex. Octal maps each digit to three bits, which fits Unix file permissions: chmod 755 means rwx (7) for the owner and r-x (5) for group and others.
Precision is the hidden trap. JavaScript numbers are 64-bit floats, so integers above 2^53 - 1 (9,007,199,254,740,991) can't all be represented, and parseInt silently rounds them. A 64-bit ID, a database snowflake or a 128-bit value converted that way comes back subtly wrong. The radix is also the second argument to parseInt and toString, so (255).toString(16) gives ff. This radix converter does the same job for bases 2, 8, 10 and 16, but parses and formats with BigInt, so a 40-digit hex string converts exactly.
The prefixes 0b, 0o and 0x come from C and are now standard in JavaScript, Python, Rust and most other languages. The results here are shown with those prefixes so they're easy to tell apart, and hex is printed in lowercase. The converter handles non-negative whole numbers; negative values and fractions aren't supported.
When developers reach for it
Decoding bit flags and masks
Paste a flags value or permission bitmask and use the binary converter output to see exactly which bits are set.
Reading hex dumps and IDs
Select Hexadecimal as the input base and the tool becomes a hex converter for values from a debugger, packet capture or hash, giving you decimal and binary alongside.
Working out file permissions
Use it as an octal converter for chmod modes like 644 or 755 to see the read, write and execute bits for each group in binary.
Checking large integers
Convert 64-bit IDs and other big numbers without the rounding that JavaScript's Number type introduces.
Frequently asked questions
How do I convert hexadecimal to decimal by hand?
+
Multiply each digit by 16 raised to its position, counting from 0 on the right, and add the results. For 0x1f that's 1 x 16 + 15 x 1 = 31.
Can I paste values with a 0x or 0b prefix?
+
Yes, as long as the prefix matches the selected input base: 0x for hexadecimal, 0b for binary, 0o for octal. Decimal input takes plain digits.
How large a number can I convert?
+
There's no practical limit. The tool uses JavaScript's BigInt, so values well beyond 2^64 convert without losing precision.
Does it support negative numbers or fractions?
+
No. It converts non-negative integers only. For negative numbers you'd also need to choose a representation, such as two's complement at a fixed bit width.
Why are Unix file permissions written in octal?
+
Each permission group (owner, group, others) has three bits: read, write and execute. One octal digit covers exactly three bits, so 755 maps neatly to rwxr-xr-x.
How do I convert decimal to hex?
+
Divide by 16 repeatedly and read the remainders from last to first. For 255: 255 ÷ 16 is 15 remainder 15, then 15 ÷ 16 is 0 remainder 15, so the result is ff. Or select Decimal as the input base and read the hexadecimal result.
How does a binary to decimal converter work?
+
Each binary digit is worth twice the one to its right, so add up the powers of two wherever there's a 1. For 0b1011 that's 8 + 0 + 2 + 1 = 11.
Related tools
SHA-256 Hash Generator
Compute SHA-1, SHA-256, SHA-384, and SHA-512 cryptographic hashes from any text using the Web Crypto API. All processing stays in your browser.
Base64 Decoder & Encoder
Encode text or files to Base64 format or decode Base64 strings.
Unix Timestamp Converter
Convert between Unix timestamps and human-readable dates. Live clock, multiple formats, seconds & milliseconds.
Chmod Calculator
Work out Unix file permissions: tick read/write/execute for owner, group and others, or type an octal mode like 755 or a string like rwxr-xr-x. Get the chmod command in numeric and symbolic form, including setuid, setgid and sticky bits.