Skip to main content

Number Base Converter

Convert a number between binary, octal, decimal and hexadecimal at once. Handles arbitrarily large values with BigInt and negative numbers too.

Enter a value in binary, octal, decimal or hexadecimal and see it in all four at once, along with the number of bits it occupies. Large values are handled with BigInt, so precision does not quietly disappear above the usual safe-integer limit.

Number Base Converter
BIN
—
OCT
—
DEC
—
HEX
—

// Number Base Converter: Features

All four bases at once

Rather than converting from one base to another, the tool shows every representation simultaneously. That suits the situations where these conversions actually arise: reading a permission mask, checking a bit flag against a hex constant, or working out which bits a value has set. Each result can be copied individually, and the bit length is shown beneath, which is often the number you actually wanted.

Large numbers keep their precision

JavaScript numbers are double-precision floats and lose exactness above about nine quadrillion, which silently corrupts large identifiers and 64-bit values. Conversion here uses BigInt once a value exceeds the safe-integer range, so a full 64-bit hexadecimal constant round-trips exactly rather than arriving slightly wrong. This is the failure mode that makes a hand-rolled converter untrustworthy for exactly the values you most want to check.

Where each base shows up

Hexadecimal is compact and maps cleanly onto bytes, with one byte always two digits, which is why it dominates memory addresses, colour codes, hashes and byte dumps. Octal survives mainly in Unix file permissions, where three bits map neatly to one digit. Binary is how you read a bit field or a subnet mask when you need to see the individual bits. Decimal is for people.

Negative values

Negative numbers are accepted and shown with a leading minus sign in every base. That is the mathematical representation rather than the machine one: a computer stores a negative integer in two's complement, where negative one in an eight-bit field is 11111111 rather than a signed minus. If you are debugging a register or a binary protocol, expect the machine representation to differ from what a base converter shows.

Working out Unix permission values

Conversion runs in the page and nothing you enter is transmitted, stored or logged. For working out Unix permission values specifically, the chmod Calculator builds the octal value from checkboxes and shows the symbolic form beside it, which is usually more direct than converting by hand.

// Number Base Converter: FAQ

Which bases are supported?

Binary, octal, decimal and hexadecimal, shown together. Enter a value in any one of them and the other three update immediately, each with its own copy button.

Can it handle very large numbers?

Yes. Values beyond the safe-integer range are converted using BigInt, so a 64-bit constant keeps every digit. This matters because a naive conversion through ordinary JavaScript numbers loses precision above about nine quadrillion without any warning.

Are negative numbers supported?

Yes, shown with a leading minus sign in each base. Note that this is the mathematical form, not the two's complement representation a machine uses: negative one is displayed as minus one in binary rather than as a row of ones.

Why is my hex value rejected?

Because it contains a character that is not valid in that base, and the error names which base it was checked against. The usual culprits are a 0x prefix, a trailing h, or the letter O standing in for a zero. Enter the digits alone, without a prefix.

What does the bit count tell me?

How many bits the value occupies, which is the number you need when choosing a column width, checking whether something fits in a 32-bit field, or confirming that a mask covers the range you expect. It is often more useful than the conversions themselves.

Why is hexadecimal used so widely?

Because it maps exactly onto bytes: four bits per digit means one byte is always two digits, and a 32-bit word is always eight. That makes memory addresses, colour values and hashes readable at a glance in a way decimal does not, while staying far more compact than binary.

Where is octal still used?

Chiefly in Unix file permissions, where read, write and execute map neatly onto three bits and therefore onto a single octal digit. That is why 755 and 644 are written the way they are. Outside permissions and a few legacy formats, octal is rarely encountered today.

Does it convert fractional values?

No, it works with integers. Fractional values in non-decimal bases follow different conventions and are far less commonly needed; if you are working with floating-point representations, you want a tool that shows the sign, exponent and mantissa fields rather than a base converter.

Can I paste a value with a prefix such as 0b or 0x?

Enter the digits without a prefix and select the base explicitly. Prefixes vary between languages, and requiring an explicit choice avoids a value being read in the wrong base because of a convention mismatch.

Is the number I enter sent to a server?

No. The conversion is arithmetic performed in your browser, and nothing you enter leaves the page.

// How to Use Number Base Converter

  1. Choose the input base

    Select whether the value you are about to enter is binary, octal, decimal or hexadecimal. Enter the digits without any prefix such as 0x or 0b.

  2. Type the value

    All four representations update as you type. An invalid character is reported with the base it was checked against, which usually points straight at a stray prefix or a letter O in place of a zero.

  3. Copy the representation you need

    Each representation has its own copy button. The bit count beneath is worth a glance when you are deciding whether a value fits a field of a given width.

Category Utilities