FileKiln

Number Base Converter

Convert numbers between binary, decimal, hexadecimal, and octal, at any size, in your browser. Byte-grouped binary included.

Ready when you arebase convert
Runs on your computer. Nothing gets uploaded.

Your stuff stays yours. The conversion happens in this page's JavaScript. Nothing you paste here leaves your machine, and the tool keeps working with the network unplugged.

Paste a number in any of the four programmer bases - decimal, hex (0x), binary (0b), or octal (0o) - and read off all of them at once, plus a byte-grouped binary view and the bit length. Conversion uses arbitrary-precision integers, so 64-bit values, 256-bit hashes, and anything else convert exactly; there is no silent precision loss at 2⁵³, which is where converters built on ordinary JavaScript numbers start quietly corrupting results. Underscores and spaces in the input are ignored, so 0xdead_beef pastes straight from source code.

How to use the number base converter

  1. Type or paste a whole number into the Number in box. Write decimal as plain digits and mark other bases with a prefix: 0x for hex, 0b for binary, 0o for octal. Prefixes and hex digits can be upper or lower case.
  2. Add a leading - for a negative number if you need one.
  3. Click Convert.
  4. Read the six lines in the All bases out box: decimal, hex, octal, binary, bytes, and bits. Hex output uses lowercase digits.
  5. Click Copy result to copy all six lines, or Clear to start again.

How the bases relate to each other

Every base works the same way: each digit is worth the base times as much as the digit to its right. In decimal, 255 means 2 hundreds, 5 tens, and 5 ones. In hex, 0xff means 15 sixteens plus 15 ones, which is also 255. Hex uses the letters a to f for the values 10 to 15.

Programmers use hex, octal, and binary because they map cleanly onto bits. One hex digit is exactly four bits, so two hex digits are always one byte: 0xde is 11011110. One octal digit is exactly three bits, which is why Unix file permissions are written in octal. 0o755 splits into 111 101 101, meaning read, write, and execute for the owner, then read and execute for the group and for everyone else. Decimal has no such alignment, which is why converting a decimal number to binary by hand takes repeated division.

The bits line counts binary digits from the highest 1 bit down, with no leading zeros. That tells you the smallest unsigned integer type that can hold the value: up to 8 bits fits in a byte, up to 16 in a uint16, and so on. The one exception is zero, which reports 1 bit.

A worked example

Paste a value copied from C or JavaScript source, underscore separators included:

0xdead_beef

Click Convert and you get:

decimal  3735928559
hex      0xdeadbeef
octal    0o33653337357
binary   0b11011110101011011011111011101111
bytes    11011110 10101101 10111110 11101111
bits     32

Each group on the bytes line matches one pair of hex digits: de, ad, be, ef. The value needs all 32 bits, so it fits in an unsigned 32-bit integer but would overflow a signed one, whose largest value is 2,147,483,647.

Signed integers are where two's complement comes in. This tool shows negative numbers as a minus sign plus the magnitude, but you can still get the two's complement pattern yourself: add 2 to the power of your bit width to the negative number and convert the result. For -42 in 8 bits, that is 256 - 42 = 214. Converting 214 gives:

decimal  214
hex      0xd6
octal    0o326
binary   0b11010110
bytes    11010110
bits     8

So -42 is stored as 0xd6 in a signed byte. For 16 bits, use 65,536 - 42 = 65,494, and for 32 bits use 4,294,967,296 - 42.

Common problems and how to fix them

0755 converted as seven hundred fifty-five

A leading zero does not mean octal here. C and non-strict JavaScript write octal as 0755, but the converter reads plain digits as decimal and ignores leading zeros, so you get 755 (0x2f3). Write 0o755 to get 493, the value chmod means.

1e3 gives an "Ambiguous digits" error

Scientific notation is not supported. Because 1e3 contains only characters that are valid hex digits, the error suggests 0x1e3, which is 483, not 1,000. Type the full number, 1000, instead.

Decimals, commas, and plus signs are rejected

Only whole numbers convert. 3.14, 1,000, and +5 all produce the format error. Remove thousands separators and the leading plus, and round or scale fractional values to integers first. For example, fixed-point money values are often stored in cents.

Two numbers merged into one

Spaces and underscores are removed before parsing, so pasting 12 34 converts 1234 with no warning. That helps with grouped digits like 1111 0000 after a 0b prefix, but convert separate values one at a time.

A hex value copied from a color or hash was rejected

Values like ff8800 or deadbeef need the 0x prefix. A value containing # or letters beyond f is not a number in any of these bases. Strip the # and add 0x.

Related tasks

If your hex value is a color, the HEX to RGB converter splits it into red, green, and blue channels. For timestamps stored as large integers, the Unix timestamp converter turns them into dates.

Questions this tool gets asked

Why does bare “ff” give an error instead of converting from hex?

Because “ff” could be hex or a typo, and guessing corrupts data. The prefixes 0x, 0b, and 0o make the base explicit, the same convention every modern language uses.

How large a number can this handle?

Effectively unlimited - conversion uses BigInt arithmetic, so 256-bit hashes and larger convert exactly. Converters that use ordinary floating-point numbers silently round anything above 9,007,199,254,740,991.

How are negative numbers shown in binary?

As a minus sign and the magnitude, not as two's complement, because two's complement is only meaningful at a fixed bit width, and this tool doesn't guess one. The bit count shown is of the magnitude.

What is the “bytes” line?

The same binary value, zero-padded to whole bytes and grouped 8 bits at a time - the way you would read it in a hex dump or when working out masks and flags.

Related tools