Skip to content
FlipConverto home

Number Base Converter

Binary to decimal, decimal to binary, hex to decimal, decimal to hex and binary to hex — any base up to 36: a number base converter that stays exact at any size, with two’s complement for negatives.

Loading Number Base Converter…

Runs entirely in your browser. What you enter stays on your device — nothing is sent to a server. Verify it yourself

How do I convert between binary, decimal and hex?

Enter the number and choose the base it is written in — or give it a 0b, 0o or 0x prefix — and every other base is shown at once. Each hex digit is exactly four binary digits, so 1111 1111 in binary is FF in hex and 255 in decimal.

Cost
Free, no limits
Upload
None — runs on your device
Sign-up
Not required
Works offline
Yes, once loaded

How to convert binary to decimal

  1. Type the number

    A whole number of any length. Prefixes 0x, 0o and 0b are understood, and spaces and underscores are ignored.

  2. Say what base it is in

    Leave Written in on Detect from prefix — no prefix means decimal — or choose any base from 2 to 36.

  3. Read and copy

    The result shows binary, octal, decimal and hexadecimal, plus one more base of your choice under Also show base. Group digits spaces long results for reading.

Examples

  • 2551111 1111 · 377 · FF

    One byte with every bit set.

  • −1 at 8 bitsTwo’s complement 1111 1111 · 0xFF

    The same pattern as 255 — the width and signedness decide how it is read.

Key features of the Number Base Converter

  • Binary, octal, decimal and hexadecimal side by side
  • Any base from 2 to 36
  • Exact for numbers of any length, far beyond 64 bits
  • Two’s complement at 8, 16, 32 and 64 bits for negatives

Supported formats

Bases

  • Binary (2)
  • Octal (8)
  • Decimal (10)
  • Hexadecimal (16)
  • Any base from 2 to 36

Input notation

  • 0b, 0o and 0x prefixes
  • Spaces, underscores or commas between digits
  • A leading minus sign

When should you use this?

  • Reading hexadecimal values in logs, memory dumps and colour codes.
  • Working out bit masks and flags in binary.
  • Checking Unix file permissions in octal.
  • Converting large IDs exactly, where a calculator would round them.

Limitations

  • Whole numbers only. Fractions are refused rather than rounded, because many cannot be written exactly in binary at all.
  • Two’s complement is shown for negative numbers, at 8, 16, 32 and 64 bits.
  • Digits above 9 are letters, so bases beyond 36 have no standard notation and are not offered.

Troubleshooting

"Not a digit in base N"

The number contains a digit the chosen base does not use — an 8 in octal, or a G in hexadecimal. Check the “Written in” setting, or add the right prefix.

An error about a 0x or 0b prefix

The prefix names a different base from the one selected. Switch “Written in” to “Detect from prefix”, or remove the prefix.

Common mistakes to avoid

  • Assuming a leading 0 means octal. Some languages once treated 010 as eight; write 0o10 to be unambiguous.
  • Reading a two’s complement pattern without knowing its width — 0xFF is 255 as an unsigned byte and −1 as a signed one.

Pro tips

Tips for better results

  • Reading binary

    Group binary in fours and it maps onto hex

    Group binary in fours and it maps straight onto hex: 1010 1111 is AF.

  • Copying

    What you copy is a clean number, without the grouping

    Copying a result drops the grouping spaces and commas, so what you paste is a clean number.

Standards and terms behind the Number Base Converter

The named things this tool works with, and the documents that define them.

Positional notationHow it works
Writing a number in a base — binary, octal, decimal or hexadecimal — where each column is worth a power of that base.
Two's complementHow it works
How computers store negative whole numbers, which is why a binary conversion needs to know the width.

Also searched as: binary to decimal, decimal to hex, hex to binary, octal conversion.

How positional bases work

In any base, each place is worth the base times the place to its right. In decimal, 255 is 2×100 + 5×10 + 5. In binary the places are 1, 2, 4, 8 and so on, so 11111111 is 255. In hexadecimal they are 1, 16, 256…, and the digits run 0–9 then A–F, so FF is 15×16 + 15 — also 255. Bases above 16 carry on through the alphabet, which is why 36, ten digits plus 26 letters, is the usual limit.

Why programmers use hex

One hexadecimal digit is exactly four bits, so two hex digits make one byte. That makes hex a compact way to read binary data: colour codes (#FF8800), memory addresses, MAC addresses and file signatures are all written in it. Octal, three bits per digit, survives mainly in Unix file permissions — the 755 in chmod 755.

Large numbers stay exact

JavaScript’s ordinary numbers are exact only up to 2⁵³ − 1, about nine quadrillion. Past that, a converter built on them quietly returns a neighbouring value, so a 64-bit ID comes back wrong. This converter uses arbitrary-precision integers, so a value of any length converts exactly.

Negative numbers and two’s complement

Mathematically, −5 in binary is −101. Computers instead store negative integers in two’s complement: invert the bits of the positive value and add one, within a fixed width. −1 is 11111111 in 8 bits and FFFFFFFF in 32. For a negative input the converter shows both the signed value and its two’s complement pattern at 8, 16, 32 or 64 bits.

Privacy

The Number Base Converter runs entirely in your browser. What you enter and the result it produces stay on your own device — nothing is sent anywhere, because nothing needs to be.

You can confirm this rather than take our word for it: open your browser’s developer tools, watch the Network tab, and use the tool. No request carries your input. It also keeps working with the connection off.

Details are in the privacy policy.

What next?

Hex colours to RGB and HSL.

Convert colour codes

Number Base Converter — questions

How do I convert binary to decimal?

Add up the place values of the 1s. For 1011 that is 8 + 2 + 1 = 11. Type it with the input set to binary, or with a 0b prefix, and every other base is shown at once.

How do I convert decimal to hexadecimal?

Divide by 16 repeatedly and read the remainders backwards, writing 10–15 as A–F. 255 gives 15 remainder 15, which is FF. The converter does this exactly for numbers of any size.

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

They are prefixes that mark the base in programming languages: 0x for hexadecimal, 0b for binary and 0o for octal. With “Detect from prefix” selected, the converter reads them automatically.

Can it convert fractions?

No — whole numbers only. Fractions such as 0.1 often cannot be written exactly in binary at all, and a converter that silently rounded them would give misleading answers.

Part of Developer Tools · Browse every tool