Skip to content
MyToolkit.pro

Code & Data

Number Base Converter

Convert integers between binary, octal, decimal and hexadecimal. Very large numbers work thanks to BigInt, negative values keep their sign, and everything stays in this browser.

Private by design: no text is uploaded or stored.

Private by design: no text is uploaded or stored.

All four bases at once

Edit any field and the other three follow. Prefixes 0b, 0o and 0x mark the input base; a bare number is decimal.

Result — options

Try an example

Result

Updates when you convert or change an option.

Bits
0
Read as
—

How does the conversion work?

Each digit of the input is validated against the source base, then the value is accumulated as a BigInt so arbitrarily large integers stay exact. The result is rendered in the target base, optionally in uppercase. A single leading minus sign is preserved, and zero always converts to "0". Nothing about your input ever leaves this browser.

Converting binary or hex to decimal: the prefix decides the base

The converter has no "from" menu. It works out the base from how you write the number in Number to convert:

You type Read as
0b1010 binary (BIN)
0o755 octal (OCT)
0xff hexadecimal (HEX)
255 (no prefix) decimal (DEC)

Prefixes are not case-sensitive, so 0XFF and 0xff give the same result. A bare ff is not read as hex. It shows an error, because without a prefix the tool only accepts decimal digits. That rule means 10 always means ten, never two or sixteen.

  1. Type or paste one integer into Number to convert. Add 0b, 0o or 0x if it isn't decimal.
  2. Read the result straight away. The four fields below the input and the result panel update as you type.
  3. Check the Read as tile to confirm which base the tool used.
  4. Check the Bits tile to see how many binary digits the value needs.
  5. To show hex digits as DEADBEEF instead of deadbeef, tick Uppercase output.
  6. Press Copy result to copy all four lines (BIN:, OCT:, DEC:, HEX:) at once.

You can also type straight into one of the four fields: Binary, Octal, Decimal or Hexadecimal. In those fields you don't need a prefix. Typing ff in the Hexadecimal field is enough, and the tool writes 0xff back into the main input for you.

Worked conversions

Each block shows the four lines from the result panel. The input and the value in the Bits tile are given above each block.

Hex to decimal for 0xDEADBEEF, a common 32-bit marker value. Bits: 32.

BIN: 11011110101011011011111011101111
OCT: 33653337357
DEC: 3735928559
HEX: deadbeef

Binary to decimal for 0b1010. Bits: 4.

BIN: 1010
OCT: 12
DEC: 10
HEX: a

Octal Unix permissions to binary for 0o755. The binary line shows the rwx bits for owner, group and others. Bits: 9.

BIN: 111101101
OCT: 755
DEC: 493
HEX: 1ed

Decimal to hex for 18446744073709551615, the maximum unsigned 64-bit integer. This is larger than JavaScript's normal number type can hold exactly, and every digit is still correct. Bits: 64.

BIN: 1111111111111111111111111111111111111111111111111111111111111111
OCT: 1777777777777777777777
DEC: 18446744073709551615
HEX: ffffffffffffffff

Where a base converter saves time

  • Reading a hex dump or a debugger: paste 0x7fff and get 32767 without working it out in your head.
  • Checking bit flags: write a mask as 0b00101100 to get 44 for a config file, or type a decimal setting to see which bits it turns on.
  • File permissions: convert 0o644 to binary (110100100) to see which read and write bits are set for owner, group and others.
  • Sizing a field: the Bits tile shows whether a non-negative ID or counter fits in an unsigned 8, 16, 32 or 64-bit type. For a signed type, add one bit: 0xffffffff shows Bits: 32, so it fits a uint32 but not an int32.
  • Hex colour channels: 0xcc gives 204. For full colours with RGB and HSL, use the Color Converter.

Limits and inputs it rejects

The tool handles whole numbers only, one per conversion. When you type any of the inputs below into Number to convert, an error appears at the top of the Result panel and all four fields stay empty:

  • Fractions and scientific notation: 3.5 and 1e3 are rejected.
  • Digit separators: 1_000, 1,000 and 1 000 are rejected. Remove the separators first.
  • Digits that don't belong to the base: 0b102 fails because 2 is not a binary digit.
  • A prefix with no digits after it, such as 0x.
  • Hex letters without a 0x prefix in the main input.

Spaces before or after the number are ignored. A negative number is converted as a minus sign plus its magnitude, so -42 gives -101010 in binary and -2a in hex. The tool does not produce two's complement, so -1 will not come back as ffffffff. If you need the bit pattern a signed 32-bit register would hold, add 2³² to the negative value first: -42 + 4294967296 = 4294967254, which converts to ffffffd6.

There is no fixed bit width such as 8, 16, 32 or 64. Thanks to BigInt, inputs hundreds of digits long stay exact. Only bases 2, 8, 10 and 16 are shown.

If your binary string is encoded text, such as 01001000 01101001, you want to decode characters, not convert one number. Use Binary to text instead.

Frequently asked questions

How do I convert hex to decimal by hand?

Multiply each hex digit by 16 raised to its position, counting from 0 on the right, and add the results. For 0x1A that is 1×16 + 10×1 = 26, the same value the tool shows in the DEC line.

How do I convert decimal to binary by hand?

Divide the number by 2 again and again, writing down each remainder, until you reach 0. Then read the remainders from last to first. For 13 the remainders are 1, 0, 1, 1, so 13 is 1101 in binary.

Why is 11111111 in binary equal to 255?

Eight binary 1s add up to 128+64+32+16+8+4+2+1 = 255. That is the largest value one byte can hold, which is why 255 and 0xff come up so often.

How many bits do I need to store a signed number?

For a value from 0 to n, a signed type needs floor(log2 n) + 2 bits, one more than unsigned. Negative values reach one step further: an 8-bit signed type holds −128 to 127, which is why 255 fits in a uint8 but not in an int8.

All in Code & Data

Text to Binary

Convert text to binary and binary back to text in your browser. Pick the direction, get clean space-separated bytes. Nothing is uploaded.

Code & Data In your browser

Binary to text

Decode binary back into readable text. Enter 8-bit groups separated by spaces and get the original characters, decoded as UTF-8 so it round-trips with the text-to-binary tool. Runs in your browser.

Code & Data In your browser

Unit Converter

Convert length, mass, area, volume, data and time units in your browser. Pick a category, a source and a target unit and get an instant result. Nothing is uploaded.

Calculators In your browser

Roman Numeral Converter

Convert numbers to Roman numerals and back in your browser. Numbers 1–3999, correct subtractive form, instant results. Nothing is uploaded.

Calculators In your browser

Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 to text instantly in your browser.

Code & Data In your browser

JSON to CSV

Convert a JSON array of objects to CSV in your browser. Choose the delimiter, keep or drop the header row, with correct quoting. Nothing is uploaded.

Code & Data In your browser

What do you need?

Swipe up for the next one