Toolbox Hub
All Tools

Number Base Converter

Binary octal decimal hex

Binary octal decimal hex Runs locally in your browser

Leave the base on Auto and the converter reads 0x, 0b and 0o prefixes for you. Pick a base to force one.

Decimal

597

Hexadecimal

255

Binary

1001 0101 01

Octal

1125

Result
Decimal: 597
Binary: 1001 0101 01
Octal: 1125
Hex: 255

About the

The Number Base Converter converts a value between binary, octal, decimal and hexadecimal, and shows all four at once so you can read whichever you need. Leave the base on Auto and it reads the 0x, 0b and 0o prefixes for you, which means you can paste 0xFF straight from source code and get 255, 1111 1111 and 377 without setting anything. Values are handled as arbitrary-precision integers, so a 64-bit value converts exactly instead of losing its top bits.

Where people use the

  • Reading a hexadecimal value from source code as decimal and binary.
  • Checking which bits are set in a flag or a mask.
  • Converting a colour value between hex and decimal channels.
  • Verifying a binary literal in a config file before you commit it.

How to use the

  1. 1

    Enter a value

    Type a number in any base: 255, 0xFF, 0b11111111 or 0o377. Spaces and underscores are ignored.

  2. 2

    Leave the base on Auto, or force one

    Auto reads the prefix and falls back to matching the digits. Pick Binary, Octal, Decimal or Hex to force an interpretation.

  3. 3

    Read all four

    Decimal, hexadecimal, binary and octal are shown together. Binary is grouped in fours to make it readable.

  4. 4

    Copy what you need

    Each row has its own copy button, and the combined result can be copied in one go.

Tips and best practices

  • Paste 0x values straight from code; the prefix is read automatically.
  • Binary output is grouped in fours to match how nibbles map to hex digits.
  • Force a base when a bare number could be read two ways, such as 10.

Frequently asked questions

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

They mark the base: 0x for hexadecimal, 0b for binary and 0o for octal. They are the conventions used by C, JavaScript, Python and most other languages, so code can be pasted in directly.

Why is my binary value rejected when I force base 2?

Because it contains characters other than 0 and 1. A value with spaces is fine, but a value with a 0b prefix is not, since the prefix is not a binary digit.

Can it handle very large numbers?

Yes. Values are handled as arbitrary-precision integers, so a 64-bit or larger value converts exactly. Only whole numbers are supported.

Does it handle negative numbers?

Yes. A leading minus is kept and shown on every base.

Can it convert fractional values?

No. The converter works on integers only, which covers the cases that matter for bit flags, addresses and colour values.

Related Tools