Tool guideConversion & Calculation Tools

Number Base Converter – Complete Guide to Binary, Octal, Decimal and Hex

How bases 2 to 36 work, how the NetTools.tech converter reads prefixes and separators, converts arbitrarily large integers exactly with BigInt, and shows two's-complement patterns for negative numbers.

By NetTools.tech · · 8 min read

A hex dump shows 0xC0A80101, a firewall rule expects a decimal integer, a permissions bitmask is written in octal, and a hardware register in the datasheet is binary. Converting by hand is slow and error-prone, and the usual calculator apps lose precision once a value passes 2⁵³.

The Number Base Converter converts integers between binary, octal, decimal, hexadecimal and any base from 2 to 36, exactly, at any size up to 4,096 digits. It shows grouped binary and hex, the bit length, and two's-complement patterns for negative values — all in your browser.

What is the Number Base Converter?

In simple terms

You type a whole number, say which base it is written in (or let the tool detect it from a prefix), and the tool writes the same number in binary, octal, decimal, hexadecimal and one extra base of your choice.

Technical background

In positional notation with base b, each digit is multiplied by a power of b. 2F in base 16 is 2 × 16¹ + 15 × 16⁰ = 47. Base b uses digits 0 to b − 1; above 9 the letters A–Z stand for 10–35, which is why 36 is the largest base with this digit set.

Some bases line up with bits: one hex digit is exactly four bits (a nibble), one octal digit three bits, and two hex digits make a byte. That is why hex is used for memory addresses, MAC addresses and IPv6, and octal for Unix file modes such as 0755.

Computers store negative integers in two's complement: in an n-bit field, a negative value v is stored as 2ⁿ + v. In 8 bits, −1 is 11111111 and −128 is 10000000; −129 does not fit. Mathematical notation, by contrast, simply writes a minus sign in front of the digits.

Why use the Number Base Converter?

  • Exactness at any size. Spreadsheet and many calculator apps use 64-bit floating point and silently round integers above 9,007,199,254,740,991. This tool uses arbitrary-precision integers (BigInt), so 0x followed by 64 f digits converts to exactly 2²⁵⁶ − 1.
  • Readable binary and hex. Grouping in 4-bit nibbles and byte pairs makes bit fields visible.
  • Signed values. The two's-complement view answers "what does −2 look like in a 16-bit register?" without manual inversion.
  • Uncommon bases. Base 36 identifiers, base 32 or base 3 exercises work the same way as hex.
  • Clear errors. An invalid digit is reported with its position and the digits allowed in that base.

Who should use it?

Developers reading hex dumps, protocol fields or bitmasks; network engineers moving between binary masks, hex and decimal; embedded and hardware engineers working with registers; security analysts decoding values in logs; and students learning number systems. For IP addresses specifically, the IP Address Converter adds dotted forms and reverse-DNS names.

How the Number Base Converter works

The conversion runs entirely in your browser.

  1. Cleaning the input. Leading and trailing whitespace is removed; spaces, underscores and apostrophes inside the number are ignored, so 1111_0000 1010 and 1'000'000 work. Letters are case-insensitive.
  2. Sign and prefix. An optional + or - comes first. Then a 0b, 0o or 0x prefix is recognized. With the input base set to Auto, a prefix selects base 2, 8 or 16 and no prefix means decimal. With an explicit base, a prefix must match it, otherwise you get "The prefix 0x means base 16, but base 2 is selected." The exception is a prefix that is itself valid digits in the selected base: in base 16, 0b1 is the hex number B1, and in base 36 0x10 is read as digits too.
  3. Digit check. Each digit must be valid for the base. A wrong digit produces an error such as "“2” at position 1 is not a base-2 digit (allowed: 0–1)". At most 4,096 digits are accepted.
  4. Exact value. Digits are accumulated into a BigInt: value = value × base + digit.
  5. Output. The value is written in bases 2, 8, 10 and 16 plus the selected extra base, using the platform's exact integer-to-string conversion. Letters are uppercase by default.
  6. Extras. Bit length is the number of binary digits of the magnitude (0 counts as 1 bit). Bytes needed is bit length ÷ 8, rounded up. For negative numbers the tool computes the two's-complement pattern for 8, 16, 32 and 64 bits and shows each width in which the value fits, with its hex equivalent.

Grouping is display-only: binary is padded with leading zeros to whole nibbles and grouped in fours; hex is padded to whole bytes and grouped in pairs. The copy buttons and exports use the plain, ungrouped digits.

How to use the NetTools.tech Number Base Converter

  1. Open the Number Base Converter.
  2. Type the value in Number, for example 255, 0xFF, 0b1010_1010 or -128.
  3. Choose the Input base: Auto (decimal or prefix) or a specific base from 2 to 36.
  4. Choose an Extra output base (default 36). If you choose 2, 8, 10 or 16, no extra line is added because those are always shown.
  5. Under Display, toggle Uppercase letters (A–Z) and Group binary/hex digits.
  6. Swap input ⇄ extra base turns the extra output into the new input, so you can check a round trip. Reset restores 255 with Auto and base 36.
  7. Use the chips under Try: for ready-made examples, and CSV, JSON, Copy all or Print to export the result list with its assumptions.

Understanding the results

ResultMeaningWhat to look for
Binary (base 2)Value in binary, grouped in nibbles when grouping is onLeading zeros are display padding only
Octal (base 8)Value in octalNo 0o prefix is added to output
Decimal (base 10)Value in decimal (highlighted)Useful as the reference for checks
Hexadecimal (base 16)Value in hex, grouped in byte pairsUppercase or lowercase per the Display option
Base nYour extra base, if it is not 2, 8, 10 or 16Letters A–Z represent 10–35
Bit lengthBinary digits of the magnitude255 is 8 bits, 256 is 9
Bytes neededBit length ÷ 8, rounded upUnsigned view; signed values may need one more bit
Two's complement (8/16/32/64-bit)Stored bit pattern of a negative value, with hex noteA missing width means the value does not fit

Example: decoding −128 and a 64-bit maximum

Enter -128 with the input base on Auto:

text
Binary (base 2)        -1000 0000
Octal (base 8)         -200
Decimal (base 10)      -128
Hexadecimal (base 16)  -80
Base 36                -3K
Bit length             8 bits
Bytes needed           1
Two's complement (8-bit)   1000 0000         hex 80
Two's complement (16-bit)  1111 1111 1000 0000   hex FF80
Two's complement (32-bit)  1111 1111 1111 1111 1111 1111 1000 0000   hex FFFFFF80
Two's complement (64-bit)  1111 … 1111 1000 0000   hex FFFFFFFFFFFFFF80

(The 64-bit line is shortened here; the tool prints all 16 groups: fourteen 1111 groups followed by 1000 0000.)

The 8-bit pattern 10000000 is the smallest signed byte. Now enter 18446744073709551615 (2⁶⁴ − 1): hex is FF FF FF FF FF FF FF FF, bit length 64, bytes needed 8, base 36 3W5E11264SGSF. No two's-complement lines appear, because the value is positive.

A second quick check: 0b1010_1010 (Auto) is 170 decimal, AA hex, 252 octal.

Common use cases

  • Converting hex values from packet captures, xxd dumps or registry entries to decimal.
  • Reading octal Unix permissions (755 octal is binary 111 101 101).
  • Checking flag bitmasks: which bits are set in 0x1F4?
  • Interpreting signed integers stored in fixed-width fields, such as a sensor value 0xFF80 in a 16-bit register (−128).
  • Producing base-36 short identifiers or decoding them.
  • Teaching or learning positional notation with real examples.

Troubleshooting

"is not a base-N digit"

The highlighted character is not valid in the selected base — for example 8 in octal or G in hex. Check the input base select; Auto means decimal unless a prefix is present.

"The prefix 0x means base 16, but base 2 is selected"

You chose an explicit base and the input starts with a different prefix that is not valid in that base, such as 0x10 with Binary selected. Set the input base to Auto, or remove the prefix. A prefix that is valid digits in the selected base (such as 0b1 in hex) is read as digits and does not trigger this message.

"Enter digits after the prefix"

The input is only 0x, 0b or 0o. Add the digits.

The two's-complement lines are missing

They only appear for negative numbers, and only for widths that can hold the value. -129 has no 8-bit line because an 8-bit signed field ranges from −128 to 127.

Common mistakes

  • Expecting fractions to convert. 0.5 or 1e3 are rejected; only integers are supported.
  • Reading grouped output as separate numbers. 1101 0110 is one 8-bit value; spaces are only for readability.
  • Confusing the sign with the stored pattern. -80 hex is a mathematical value; the byte a CPU stores is 80, and in 16 bits FF80.
  • Assuming Bytes needed covers signed storage. It measures the magnitude; +128 has bit length 8 but needs 9 bits as a signed value.
  • Pasting C-style octal. A leading 0 (as in 0755) is not an octal prefix here; with Auto it is read as decimal 755. Use 0o755 or select base 8.

Limitations

  • Integers only, no fractions, floating-point formats or fixed-point values.
  • Two's complement is shown for 8, 16, 32 and 64 bits only, and only for negative inputs.
  • No other signed representations (ones' complement, sign-magnitude) and no byte-order (endianness) swapping.
  • Digit sets are fixed: 0–9 then A–Z. Encodings such as Base64 or Base32 alphabets (RFC 4648) are not the same as base 64 or base 32 positional notation and are not supported.
  • Maximum 4,096 digits per input.

Security & privacy

The conversion happens locally in your browser and the number you enter is not transmitted. The page may send an anonymous usage counter (tool name and view/run, no inputs or results) unless your browser signals Global Privacy Control or Do Not Track. Hex strings are sometimes secrets — private keys, API tokens, session IDs — so do not paste those into any web page you do not need to; this tool does not need them.

Summary

The Number Base Converter writes any integer in bases 2 to 36 exactly, using BigInt rather than floating point, with grouped binary and hex for readability. It recognizes 0x, 0b and 0o prefixes, reports invalid digits by position, and shows two's-complement patterns for negative values in common register widths. It does not handle fractions, floating-point layouts or Base64-style encodings.

Frequently asked questions

What do the 0x, 0b and 0o prefixes mean?

They mark the base in source code and many tools: 0x for hexadecimal (base 16), 0b for binary (base 2) and 0o for octal (base 8). The converter accepts them; with the input base on Auto they select the base, and with an explicit base they must match it or you get an error — unless the prefix is itself valid digits in that base, such as 0b1 in base 16, which is then read as digits.

Can the converter handle fractions or floating-point numbers?

No. It converts whole numbers (integers), including negative ones and very large ones. Fractions often have no finite representation in another base, and floating-point bit layouts (IEEE 754) are a different topic.

How are negative numbers shown?

Every base shows the value with a minus sign, for example -128 is -10000000 in binary. In addition, for negative numbers the tool lists the two's-complement bit pattern in 8, 16, 32 and 64 bits wherever the value fits, with the matching hex form.

Is there a size limit?

Inputs may have up to 4,096 digits after the sign and prefix are removed. Within that limit the conversion is exact, because it uses JavaScript BigInt instead of floating-point numbers.

Is 0b1 read as binary when I select base 16?

No. With an explicit base, a leading 0b, 0o or 0x counts as a prefix only when it is not valid digits in that base. In base 16, 0b1 is the hex number B1 (177 decimal); to enter binary, switch the input base to Auto or Binary.

What does Bytes needed mean?

It is the bit length of the number's magnitude divided by 8 and rounded up. For negative numbers it counts the magnitude only, so check the two's-complement lines to see which fixed widths can actually hold the signed value.