Base Converter

Convert between binary, octal, decimal and hexadecimal

Hex format:

The same number wears a different face depending on where you meet it: Linux permissions arrive as octal 755, memory addresses and error codes as hexadecimal 0x8007000E, and a bit-flag column only reveals which switches are on once you spread it out in binary. This tool lays base 2, 8, 10 and 16 side by side as four input fields — type in any one of them and the other three follow immediately, with no source or target picker in between. Every conversion runs in the browser on your own machine.

How to use it

  1. Four fields sit side by side: "Binary (base 2)", "Octal (base 8)", "Decimal (base 10)" and "Hexadecimal (base 16)". Type into whichever one you have a value for and the other three update on every keystroke — there is no Convert button and no dropdown for choosing directions.
  2. Each field has its own copy button to its right, which copies exactly what that field currently shows.
  3. Each field accepts only its own alphabet: 0 and 1 for binary, 0–7 for octal, 0–9 for decimal, 0–9 plus a–f (either case) for hexadecimal, with an optional leading minus sign. Anything else turns that field's border red and puts a message like "Invalid hexadecimal character" underneath it.
  4. The button next to "Hex format:" at the bottom toggles between "Uppercase (A-F)" and "Lowercase (a-f)". The label names the mode you are currently in; pressing it rewrites whatever is already in the hexadecimal field and governs every later conversion, and even the field's placeholder swaps between 1A2B and 1a2b.
  5. Clearing any one field clears all four. A lone minus sign leaves the other three blank while it waits for the rest of the number.
  6. When a value leaves the JavaScript safe integer range, an amber warning strip appears above the four fields. It has one blind spot, described in the notes below.

When it comes in handy

Read and write Linux file permissions

The 755 in chmod 755 is octal, one digit each for owner, group and other. Paste 755 into the octal field and binary shows 111101101, which splits into rwx r-x r-x. Going the other way, type 110100100 in binary when you want "owner reads and writes, everyone else reads" and octal hands you 644.

Unpack a bit-flag column

Your database says permissions = 22 and the code defines READ=1, WRITE=2, DELETE=4, SHARE=16. Put 22 in the decimal field, read 10110 in binary, and bits 2, 3 and 5 counting from the right are set: WRITE + DELETE + SHARE. More reliable than doing the masking in your head, and faster than opening a REPL.

Cross-check hexadecimal from logs and debuggers

Crash codes like 0x8007000E, register dumps, length fields in a packet capture — all of them are written in hex. To line one up with a decimal value from the application layer (does the length field 1F4 really equal the 500 you expected?), paste it into the hexadecimal field and read the decimal one. Strip the 0x prefix first.

Check homework and teach the relationship between bases

Converting decimal to binary by hand tends to go wrong in the last few digits. Type your answer into binary and see whether decimal agrees. Having all four visible at once also makes the digit ratios obvious: change hexadecimal F to 10 and binary jumps from 1111 to 10000, which is one hex digit standing in for exactly four binary ones.

Limits and behavior

  • Integers only, and the restriction is enforced at the keyboard rather than after the fact. The decimal field's alphabet has no decimal point, so 3.14 turns red the moment you type it instead of producing a wrong answer. The same applies to a binary fraction such as 1011.1.
  • The fields rewrite themselves as you type. Every keystroke recomputes and writes back all four values, including the one under your cursor. That is why leading zeros will not stick — finish typing 007 and the field holds 7 — and why typing lowercase ff in uppercase mode shows FF before you have released the second key. The control is normalising the value, not the copy button.
  • The conversion path is parse the string, hold it as a double-precision float, print it in the target base. Anything past 2^53 - 1 therefore does not survive the round trip. Type 55 ones into binary — that is 36028797018963967 — and decimal reads 36028797018963970 while the binary field rewrites itself to a 1 followed by 55 zeros, one digit longer than what you typed.
  • The amber warning has a blind spot, and it opens up exactly where you need the warning most. The check re-parses the **string** sitting in the decimal field and compares it against 2^53 - 1. Past 10^21 that string is already in exponential form — 4.722366482869645e+21 — so the parser stops at the first period, gets 4, and the comparison quietly fails. Try it: put eighteen F characters in the hexadecimal field. It rewrites itself to 1000000000000000000, decimal shows the exponential string above, and nothing warns you at all. Treat an e+ in the decimal field as the real red light.
  • Negatives use a leading minus sign, not two's complement. You cannot make a 32-bit FFFFFFFF read as -1 here; it honestly reports 4294967295. To recover the signed value, check the top bit yourself: if the decimal result exceeds 2^31 - 1, subtract 2^32. The reverse holds too — typing -1 in decimal gives -1 in hexadecimal, not FFFFFFFF.
  • No prefixes are accepted. 0x1A, 0b1010, #FF6600, and assembly conventions like $1A or a trailing h all turn red, because x, b, #, $ and h are outside the permitted alphabets. Trim the prefix off values copied from source or CSS. Output carries no prefix either, so add it back when you paste into code.
  • When one field is flagged, the other three do not clear — they stay on the last value that converted successfully. So you can be looking at a red string of nonsense alongside three perfectly plausible numbers that have nothing to do with it. Fix the invalid characters and all four resynchronise.
  • These four bases are all there is. There is no arbitrary-radix field, so base32, base36 and Crockford Base32 are out of scope. Base64 is often mistaken for "base 64" in this sense; it is a way of re-encoding a byte string into printable characters, and it operates on arbitrary binary data rather than on a numeric value.
  • Nothing you type leaves the tab. The arithmetic happens in your browser and no value is recorded anywhere. For completeness: this page, like the rest of the site, pulls in third-party advertising resources, and that traffic never touches the contents of the four fields.

Frequently asked questions

Why does pasting `0x1A` turn the whole field red?

The hexadecimal field accepts 0–9 and a–f; x is not one of them. Literal prefixes from C, Python, CSS and JSON schemas all have to come off first — paste 1A and it works. The same goes for a 0b binary prefix, and for the older assembly style that puts the radix at the end, as in 1Ah.

Why did the decimal field turn into something like `4.722366482869645e+21`?

Because the value grew large enough that the browser prints its decimal string in exponential form. Seeing that means precision was lost some time ago, and it also means the safe-integer warning will not light up, since its comparison cannot read an exponential string. Numbers at that scale — snowflake IDs, 64-bit primary keys, a UUID treated as an integer — belong in a big-integer type on the server, not in this converter.

The last digit I typed changed by itself. Did I mistype?

No. Type 9007199254740993 into decimal and the field settles on 9007199254740992. Your input is two above the safe integer ceiling, and at that magnitude a double can no longer represent odd numbers, so the nearest representable value is that even one. Every input past 2^53 - 1 gets pulled onto a nearby representable value, silently.

Why can I not type a binary fraction like `1011.1`?

The alphabet is 0, 1 and a leading minus, so the period is rejected on the spot. Binary fractions are really a question of how a mantissa and exponent are laid out — the IEEE 754 story — which is a different problem from integer base conversion and one this tool does not touch. For the bit pattern behind a particular decimal fraction you want a dedicated floating-point layout viewer.

Does the "Uppercase (A-F)" button show the current mode or what pressing it will do?

The current mode. When it reads "Uppercase (A-F)" the hexadecimal field is uppercase right now; press it and the value switches to lowercase while the label becomes "Lowercase (a-f)". The setting only affects how the six letters A–F are drawn — digits and the underlying value are untouched, and FF and ff are the same 255.

Can I convert a whole list of numbers at once?

No — all four are single-line inputs handling one value at a time. Pasting a newline-separated list flags the field, because the newline itself is not a permitted character. For bulk work use spreadsheet functions such as DEC2HEX and HEX2DEC, or a short loop in whatever language is already open.