Command Palette

Search for a command to run...

Number Base Converter: Binary, Octal, Decimal, Hex, and Everything to Base 36

T
Toolz Team
|Jul 17, 2026|23 min read

The first time a base conversion cost me a working evening, the culprit was a permissions bug. A deploy script wrote file modes as chmod 755, and a config loader read the same value out of a JSON file as the number 755. JSON has no octal literal. The loader passed 755 to a syscall that expected an octal mode, the mode was interpreted as decimal 755, and decimal 755 in binary is 1011110011 — ten bits of nonsense in a nine-bit field. Files ended up with permissions nobody had asked for and nobody could explain.

That is what base confusion looks like in practice. It is almost never a hard math problem. It is a value that is correct in one notation and catastrophic in another, moving across a boundary where nobody wrote down which base was intended. Binary, octal, decimal, and hexadecimal are four ways to write the same integer, and a computer will happily let you mix them up.

So I built the Number Base Converter on toolz.dev to be the thing I actually reach for at that moment: paste a value, say what base it is in, and see it in every other base at once — along with the bit count, the byte count, and the binary laid out in nibbles so it lines up with the hex digits above it. It handles any radix from 2 to 36, it accepts 0x, 0b, and 0o prefixes, and it does all of its arithmetic in BigInt, so a 256-bit hash converts exactly instead of quietly rounding into garbage.

TL;DR: A number's value never changes when you convert it — only the notation does. The Number Base Converter converts integers between any bases from 2 to 36, shows binary, octal, decimal, and hexadecimal simultaneously, reports bit and byte length, uses BigInt so precision holds at any size, and runs entirely in your browser.

Key Features

Any base from 2 to 36

Binary, octal, decimal, and hexadecimal get dedicated shortcut buttons because they are the four that appear in real code. But the source and target dropdowns run the full range from base 2 to base 36 — the ceiling being the point where you run out of case-insensitive alphanumerics (ten digits plus twenty-six letters). Base 3, base 12, base 20, base 32, and base 36 are all one click away, and each renders with the standard 0-9A-Z digit alphabet.

Exact BigInt arithmetic

This is the feature that matters most and shows up least in marketing copy. JavaScript numbers are IEEE-754 doubles, and they represent integers exactly only up to 2^53 − 1, which is 9,007,199,254,740,991. Past that, parseInt and Number start rounding — silently, without an error, producing a value that looks plausible and is wrong. Most base converters on the web are built on exactly those functions.

This one parses digit by digit into a BigInt accumulator (value = value * base + digit) and renders back out by repeated division. There is no precision ceiling. A 64-bit ID, a 256-bit hash, an RSA modulus, a 500-digit decimal — all convert exactly.

All bases at once

One input, four outputs, live. The panel shows binary, octal, decimal, and hexadecimal simultaneously, plus your chosen custom base if it is not one of those four. Most base conversions are really cross-checks — you want to confirm that the hex in your debugger and the decimal in your log line are the same number — and seeing all four at once turns a three-step task into a glance.

Bit length, byte length, and nibble grouping

The reason people convert to binary is usually not curiosity about the bits, it is a sizing question: does this fit in a byte, in a 32-bit int, in a signed short? So the converter reports the significant bit length (255 → 8 bits, 256 → 9 bits) and the byte length rounded up. The binary output is padded to a whole number of nibbles and grouped in fours, so each group of four bits sits directly under the hex digit it encodes.

Forgiving input, precise errors

Real-world values arrive with decoration. 0xDEADBEEF from a stack trace, 0b1010_1111 from a Rust literal, 0o755 from a chmod, FF FF FF copied out of a hex editor. All of it is accepted: prefixes are stripped when they agree with the selected base, and underscores and spaces are treated as digit separators.

When a digit is illegal for the base you chose, the error names it. Type 1092 in base 8 and you get "9" is not valid in base 8. Base 8 uses 0-7. — not a generic "invalid input", which tells you nothing about which character to go look at.

Negative number support

Negative values convert and render with a leading minus sign. That is sign-magnitude notation, and it is the honest answer, for reasons covered in the two's complement section below.

Runs entirely in your browser

No network round trip, no upload, no logging. The result updates on every keystroke because the arithmetic is happening a few microseconds away, and the page keeps working with no connection at all once it has loaded.

How to Use the Number Base Converter

Step 1: Enter your number

Type or paste the value into the From field. You do not need to strip decoration first — 0xFF, 0b1010, 0o755, 1010_1111, and DE AD BE EF are all accepted. Leading + and - signs work. Leading zeros are harmless.

Step 2: Choose the source base

Tell the converter how to read what you typed. This is the step people skip, and it is the one that matters: 101 is 5 in binary, 65 in octal, 101 in decimal, and 257 in hexadecimal. Four different numbers, one string of characters. The shortcut buttons cover binary, octal, decimal, and hex; the dropdown covers everything from 2 to 36.

If the source base cannot read a character you typed, you get a message naming that character rather than a silent wrong answer.

Step 3: Choose the target base

Pick the base you want out. The result appears immediately and updates as you type — there is no convert button, because there is no server to wait for. The swap button reverses the direction and moves the result into the input, which is the quickest way to round-trip a value and confirm it survives.

Step 4: Read the panels

Below the conversion you get:

  • All bases at once — the same value in binary, octal, decimal, and hexadecimal, plus your custom base if you picked one.
  • Bit length, byte length, hex digits — the sizing numbers.
  • Grouped binary — the bits padded and split into nibbles, aligned with the hex digits.

Step 5: Copy

Copy the bare result, or copy the full expression (255 (base 10) = FF (base 16)) when you want the conversion to be self-documenting in a commit message, a code comment, or a bug report. The second option is the one to use when you are explaining a number to someone else, because it carries the base along with the digits.

How Positional Notation Actually Works

Every base we use is a positional system, which means a digit's contribution depends on where it sits. In base b, the digit at position i (counting from zero on the right) is worth digit × b^i. That single rule generates every base.

Take 1,234 in decimal:

1×10³ + 2×10² + 3×10¹ + 4×10⁰ = 1000 + 200 + 30 + 4 = 1234

Now take 1A3 in hexadecimal, where A is 10:

1×16² + 10×16¹ + 3×16⁰ = 256 + 160 + 3 = 419

Same rule, different base. And 10101111 in binary:

1×2⁷ + 0 + 1×2⁵ + 0 + 1×2³ + 1×2² + 1×2¹ + 1×2⁰ = 128 + 32 + 8 + 4 + 2 + 1 = 175

The two algorithms that fall out of this rule are the entire converter:

Reading a number in base b is a left-to-right fold. Start at zero, and for each digit: value = value × b + digit. This is Horner's method, and it is why the converter never needs to compute b^i explicitly — no exponentiation, no floating point, no accumulated error.

Writing a value in base c is repeated division. Divide by c, keep the remainder as the next digit (from the right), repeat with the quotient until it hits zero. The remainders, read backwards, are the digits.

Both operations are exact on integers, which is why doing them in BigInt gives you a conversion with no rounding anywhere in the pipeline. The value 123456789012345678901234567890 converts to hex as 18EE90FF6C373E0EE4E3F0AD2 — 97 bits, 13 bytes — and converts back to exactly the decimal you started with. Try that in a converter built on parseInt.

There is one detail worth noting about the digit alphabet. Base 36 is the practical ceiling because it is the last base you can write with case-insensitive ASCII alphanumerics: 0-9 gives you ten digits, A-Z gives you twenty-six more, and 10 + 26 = 36. Push past it and you need case sensitivity (base 62) or a symbol alphabet (Base64), at which point you are no longer doing arithmetic notation — you are doing binary-to-text encoding, which is a different job with different rules. If that is what you actually need, use the Base64 Converter instead.

Why Hexadecimal Maps So Cleanly onto Binary

Hex is not popular in programming because it is compact. Base 10 is more compact than base 16 for the same value in terms of human familiarity, and if compactness were the goal we would use base 36. Hex won for one structural reason: 16 is 2⁴.

That means one hexadecimal digit encodes exactly four binary digits — one nibble — with no carry ever crossing the boundary between them. The mapping is a lookup table, not an arithmetic operation:

Binary Hex Binary Hex
0000 0 1000 8
0001 1 1001 9
0010 2 1010 A
0011 3 1011 B
0100 4 1100 C
0101 5 1101 D
0110 6 1110 E
0111 7 1111 F

Convert 11111111 by splitting it into 1111 1111, reading each nibble off the table, and concatenating: FF. No arithmetic. Convert 0xDEADBEEF to binary by expanding each digit: 1101 1110 1010 1101 1011 1110 1110 1111. The structure survives.

Because a byte is eight bits and a hex digit is four, one byte is always exactly two hex digits. 0x00 through 0xFF covers every possible byte, which is why hex dumps, MAC addresses, colour codes, and memory addresses are all written in hex. 0xFF tells you at a glance that you are looking at one full byte. Decimal 255 tells you nothing of the kind — you have to know that 255 is 2⁸ − 1, and you have to do the same recall for 65535 and 4294967295.

Octal works on the same principle with 8 = 2³, so one octal digit is exactly three bits. That is precisely why Unix file permissions are octal: the mode is three groups of three bits (read, write, execute for user, group, other), and three bits is one octal digit. chmod 755 is 111 101 101 — and now the digits mean something instead of being a magic number you memorized. It is also why my permissions bug happened: 755 in decimal is not 755 in octal, and nothing about the string 755 announces which one it is. The Number Base Converter exists partly so that you can settle that question in three seconds.

Two's Complement, and Why This Tool Uses a Minus Sign

Enter -42 and the converter returns -101010. Some people expect 11010110 and consider the minus sign a bug. It is not, and the reason is worth understanding because it is the single most misunderstood thing about binary.

Two's complement is not a property of a number. It is a property of a fixed-width register.

The value −1 has no canonical binary representation. In an 8-bit two's complement register it is 11111111 (0xFF). In 16 bits it is 0xFFFF. In 32 bits, 0xFFFFFFFF. In 64 bits, sixteen Fs. These are not four different ways of writing the same bit pattern; they are four different bit patterns, and which one is correct depends entirely on a width that lives in your type declaration, not in the number.

An arbitrary-precision integer — which is what a BigInt is, and what this converter works with — has no width. So the only representation that is meaningful without additional context is sign-magnitude: a minus sign followed by the magnitude's digits. That is what you get, and it is the honest answer rather than a confidently wrong one.

When you do need a two's complement pattern, the recipe is straightforward, and you can run it in this tool:

  1. Decide your width, n bits.
  2. Compute 2^n + value (with value negative). For −42 in 8 bits: 256 − 42 = 214.
  3. Convert 214 to your target base: 11010110 in binary, D6 in hex.

The mechanical shortcut you may have learned — invert every bit, then add one — produces the same result, because inverting all n bits of x gives (2^n − 1) − x, and adding one gives 2^n − x. The arithmetic identity is the same operation; the bit-flipping version is just how you do it without a divider.

A quick reference for the widths people actually use:

Width Range (signed) −1 in hex Most negative value
8-bit −128 to 127 FF 80 (−128)
16-bit −32,768 to 32,767 FFFF 8000
32-bit −2,147,483,648 to 2,147,483,647 FFFFFFFF 80000000
64-bit ±9.22 × 10¹⁸ FFFFFFFFFFFFFFFF 8000000000000000

Note the asymmetry in every row: there is one more negative value than positive, because zero occupies a slot on the positive side. That is the source of the classic overflow bug where negating the most negative integer returns itself. If you want to see the bits of a value or a string laid out directly, the Binary Translator is the companion tool for that.

What Is Base 36 For?

Base 36 looks like a curiosity and is actually the most practically useful of the "exotic" bases, for one reason: it is the densest number notation that survives being case-folded, typed by a human, and dropped into a URL without escaping.

Compare the same 64-bit value across bases:

Base Digits needed for a 64-bit value Example
Binary (2) 64 1111...
Decimal (10) 20 18446744073709551615
Hexadecimal (16) 16 FFFFFFFFFFFFFFFF
Base 36 13 3W5E11264SGSF
Base 62 11 case-sensitive

Base 36 gets you a 35% saving over hex and a 35% saving over decimal, using only characters that are safe in a URL path, safe in a filename, unambiguous over the phone, and identical whether the user types them in caps or not. That is why it shows up in short link IDs, invoice numbers, coupon codes, order references, and compact timestamps. Date.now().toString(36) is a common trick for generating a short, sortable, human-typable ID.

The trade-off is legibility: 3W5E11264SGSF is not something you can eyeball for structure the way you can with hex, and there is no clean bit alignment because 36 is not a power of two. Use base 36 when the number is an opaque identifier and the goal is compactness. Use hex when the number's bit structure is the point.

Common Use Cases

Debugging memory and hex dumps. Your debugger shows 0x7FFE4A3C, your log shows 2147330620, and you need to know if they are the same address. Paste one, read the other.

File permissions. Convert 755 from octal to binary and see 111 101 101, which is exactly the nine permission bits in the order the mode field defines them. This is the fastest way to explain to someone why chmod 644 and chmod 664 differ by one group-write bit.

Colour values. #FF5733 is three bytes: red 255, green 87, blue 51. Splitting a hex colour into its decimal components is a two-hex-digit-at-a-time conversion. For the full workflow — palettes, contrast, format conversion — the Color Picker handles it end to end, but the underlying arithmetic is exactly this.

Bit masks and flags. A flags field of 0b00101100 is 0x2C and decimal 44. When you are checking which flags are set, binary is the only readable form; when you are writing the constant into code, hex is. You need both, constantly.

Network and protocol work. Subnet masks, MAC addresses, IPv6 groups, protocol numbers, and checksums are all hex or binary in the spec and decimal in half the tooling. IP address octets in particular are decimal in dotted notation and binary the moment you touch a mask.

Hashes and identifiers. A SHA-256 output is 64 hex characters — 256 bits, 32 bytes. Converting it to decimal produces a 78-digit number, and that is exactly where every naive converter breaks, because it is roughly 10^25 times larger than the safe integer ceiling. If you are generating those hashes rather than converting them, the Hash Generator produces them client-side.

Interview and coursework problems. Base conversion is a staple of CS fundamentals, and having a reference implementation that shows the value in all four common bases at once — with the bit count — makes checking your own work fast.

Base Comparison at a Glance

Base Name Digits Bits per digit Where you see it
2 Binary 0-1 1 Bit masks, flags, hardware registers
8 Octal 0-7 3 Unix file permissions, legacy C literals
10 Decimal 0-9 ~3.32 Everything a human writes
16 Hexadecimal 0-9, A-F 4 Memory addresses, colours, hashes, bytes
32 Base 32 0-9, A-V 5 Compact case-insensitive encodings
36 Base 36 0-9, A-Z ~5.17 Short IDs, invoice codes, URL-safe numbers

The "bits per digit" column explains the whole table. Bases that are powers of two (2, 8, 16, 32) have an integer number of bits per digit, which means digits map onto bit groups with no carry crossing the boundary — that is what makes hex-to-binary a lookup rather than a calculation. Bases that are not powers of two (10, 36) have a fractional bits-per-digit, which is why converting decimal to binary genuinely requires arithmetic and cannot be done by substitution.

And the same input string can be a legal number in several bases with completely different values. 101 is a good one to keep in mind:

Read as Value
Binary 5
Octal 65
Decimal 101
Hexadecimal 257
Base 36 1,297

Five numbers, one string. The base is not a display preference — it is part of the data, and every bug in this article comes from somewhere that forgot to write it down.

For a broader look at which browser-based utilities are worth keeping within reach, I collected the ones I use daily in the web developer's toolkit.

FAQ

How do I convert decimal to binary?

Divide the number by 2 repeatedly and read the remainders from last to first. For 42: 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. Reading the remainders bottom-up gives 101010. The converter runs this in BigInt arithmetic, so it stays exact for values far beyond anything a pocket calculator can hold.

How do I convert hex to decimal?

Multiply each hexadecimal digit by 16 raised to the power of its position, counting from zero on the right, then add the products. FF is (15 × 16) + 15 = 255. 1A3 is (1 × 256) + (10 × 16) + 3 = 419. Set the source base to 16, paste the value with or without a 0x prefix, and the decimal appears immediately.

How do I convert binary to hex?

Group the binary digits into nibbles of four, starting from the right, and map each nibble to a single hex digit. 11111111 splits into 1111 and 1111, which are F and F, so the answer is FF. The grouping works because 16 is 2 to the fourth power, so one hex digit encodes exactly four bits and no carry ever crosses a group boundary. That is why hexadecimal is used for bytes: one byte is always exactly two hex digits.

Why do programmers use hexadecimal instead of decimal?

Because hex maps cleanly onto binary and decimal does not. One hex digit is exactly four bits and one byte is exactly two hex digits, so 0xFF is visibly a full byte and 0xDEADBEEF is visibly four bytes. Decimal gives you no such structure: nothing about 255 announces that it fills a byte. Hex keeps the bit layout readable while being a quarter of the length of raw binary.

Can this converter handle very large numbers?

Yes. Every value is parsed digit by digit into a BigInt, so there is no 2^53 ceiling and no floating-point rounding at any size. A 256-bit hash, a full RSA modulus, or a 500-digit decimal converts exactly. Converters built on parseInt or Number silently corrupt values above 9,007,199,254,740,991, which is precisely the range where an error is hardest to spot.

Does it support negative numbers and two's complement?

Negative values are supported and rendered with a leading minus sign, which is sign-magnitude notation. Two's complement is deliberately not applied, because it is a property of a fixed-width register rather than of a number: −1 is FF in 8 bits, FFFF in 16 bits, and FFFFFFFF in 32 bits. To produce a two's complement pattern, add 2 to the power of your chosen width to the negative value and convert the result — for −42 in 8 bits, 256 − 42 = 214, which is D6 in hex.

What is base 36 used for?

Base 36 uses the digits 0-9 followed by the letters A-Z, making it the densest number notation you can build from case-insensitive ASCII alphanumerics. It produces short, URL-safe, case-insensitive strings, which is why it appears in short link IDs, invoice codes, coupon codes, and compact timestamps. A 64-bit value takes 13 base-36 characters instead of 20 decimal digits or 16 hex digits.

What do bit length and byte length mean?

Bit length is the number of significant bits in the value's magnitude, ignoring leading zeros: 255 has a bit length of 8 and 256 has a bit length of 9. Byte length is that figure rounded up to the next multiple of eight. Together they tell you the smallest integer type the value fits into, which is usually the actual reason someone converts a number to binary in the first place.

Is my data sent to a server when I convert a number?

No. Every conversion is computed in JavaScript in your browser, which is why the result updates on each keystroke rather than after a network round trip. Nothing you type is transmitted, logged, or stored, and the converter keeps working with no network connection at all once the page has loaded.

Comments

0 comments

0/2000 characters

No comments yet. Be the first to share your thoughts!