Number Base Converter

Convert numbers between binary, decimal, hex and octal, or turn text into UTF-8 bytes and back, entirely in your browser. Nothing is ever uploaded.

🌐 Español

🔒 Private by design: your text is processed locally in your browser and never uploaded to any server.

Two converters sharing one paste box

The Conversion mode dropdown switches this page between two jobs that happen to want the same interface. Leave it on number base and you are converting an integer between binary, octal, decimal and hexadecimal. Switch it to text and you are converting between readable characters and the UTF-8 bytes that represent them, written out in binary or hex.

All four dropdowns appear at once, whichever mode is selected. Two are labelled for number mode and two for text mode, and the pair belonging to the mode you are not in has no effect on the result.

Both jobs produce a labelled report rather than one lonely number. In number mode it opens with what you typed and how it was interpreted, then gives the value in all four bases, so the usual follow-up (“and what is that in octal?”) is already answered.

Prefix detection, and what picking a base explicitly does to it

With the source base left on Auto-detect (recommended), the leading characters decide: 0x means hexadecimal, 0b means binary, 0o means octal, in either case, and anything with no prefix is read as decimal. That covers how numbers are actually written in source code, so pasting 0xFF straight out of a stylesheet or a struct definition works without touching a dropdown.

Choosing a base explicitly changes the rules in a way that is easy to trip over. The chosen base wins, and only its own prefix is stripped. Pick Hexadecimal and 0xFF loses its prefix and converts; pick Binary and 0x1F keeps every character it has, including the x, which then fails validation because x is not a binary digit. That is the intended behaviour rather than a bug: guessing that you meant hex after you explicitly said binary would be worse than refusing.

Refusals in general are strict here. Every digit is checked against the resolved base before any conversion runs, so 9 in an octal number, 2 in a binary one and g in a hex one are all rejected instead of being skipped or truncated. The page shows one generic failure message when that happens, with the specific reason written to the browser console, so the console is where to look when the cause is not obvious.

Running a number or a byte string through it

  1. Set Conversion mode first, since it decides which of the remaining dropdowns matter.
  2. For a number, leave the source base on Auto-detect unless the value has no prefix and is not decimal.
  3. For text, set the direction and choose whether bytes are written as binary or as hex.
  4. Paste the value into the box and click Number Base Converter. The button is disabled until the box has content.
  5. Read the labelled report and click Copy to clipboard, or Process another to start again with an empty box.

BigInt all the way down

Ordinary JavaScript numbers are floating point and stop being exact above 2^53-1, a little over nine quadrillion. A converter that parses input with parseInt hands back a wrong answer past that point, and it looks entirely plausible.

This one never touches that type. Digits are folded into an arbitrary-precision integer one at a time, multiplying the running total by the base and adding the next digit, so a value with dozens of digits converts exactly. That is not academic: 64-bit identifiers and large hex hashes both exceed the safe range, and both are things people paste into a base converter.

If you are working with hex digests rather than hex numbers, the SHA-256 Hash Generator produces them from text, and this page turns one into its decimal or binary form afterwards once you paste it with a 0x prefix or pick Hexadecimal as the source base.

A minus sign, not a two’s complement

Negative input is supported in the simplest possible way. A leading - is recorded and re-attached to every output, so -255 comes back as -11111111 in binary and -FF in hex. A leading + is accepted and discarded. Zero never grows a sign, so a negative zero is printed as plain 0.

This is not two’s complement, and the distinction matters if you came here from low-level work. Two’s complement represents a negative value as a specific bit pattern of a fixed width, which is why -1 appears as a run of ones in a register dump, and the width has to be agreed in advance. This page has no fixed width, so it uses the sign-and-magnitude form a mathematician would write. If what you need is the bit pattern in a register, this is not the tool that produces it.

Hex arrives uppercase, bytes arrive space separated

Output formatting is fixed and worth knowing before you compare results against something else. Hexadecimal is uppercased, in both the number report and the text-to-hex direction. Bytes are printed one per group, separated by single spaces, with binary bytes zero-padded to a full eight digits so that a byte below 128 still occupies its whole width.

That formatting is optional on input, though. Whitespace is removed before the digits are grouped, so anything produced here pastes straight back, as does a byte string from a tool that used no separators.

The text side of this page is a good companion to a hex dump: Hex Viewer shows a real file’s bytes with offsets and an ASCII column, and when a particular byte value there needs explaining, this page converts it between hex, decimal and binary. For a different kind of number system entirely, the Roman Numeral Converter handles that notation, including numbers past 3,999. And if the goal is to make bytes travel through a text-only channel rather than to read them, that is Base64 Encode rather than this page.

See it in action

Screenshot of the Number Base Converter tool with the sample input “255”, Conversion mode set to Number base (binary / decimal / hex / octal), Number mode: source base (auto-detects 0x/0b/0o prefixes) set to Auto-detect (recommended)
Number Base Converter mid-process: the sample input “255”, Conversion mode set to Number base (binary / decimal / hex / octal), Number mode: source base (auto-detects 0x/0b/0o prefixes) set to Auto-detect (recommended).
Screenshot of the Number Base Converter result screen showing the generated output “=== INPUT === 255 Interpreted as decimal. === BI…”
The finished result: the generated output “=== INPUT === 255 Interpreted as decimal. === BI…”. The download link is a local blob URL — the file never leaves your device.

Frequently asked questions

Why are the text-mode dropdowns showing while I am converting a plain number?

All four selects are rendered together, because the page has one options area rather than one per mode. Whichever pair does not belong to the conversion mode you picked is simply ignored, so leaving direction and byte format on their defaults while you convert a hex number changes nothing about the result. It is worth a second look when a conversion behaves oddly, though, since the mode dropdown is the first of the four and easy to skim past.

Can it convert a decimal fraction like 3.14 or 0.5?

No, whole numbers only. Every digit of your input is validated against the digit set of the resolved base before any arithmetic happens, and a full stop is not a valid digit in base 2, 8, 10 or 16, so a fractional value is rejected rather than silently truncated to its integer part. The underlying arithmetic uses an integer type with no fractional representation at all, which is the same reason it can be exact for very large values.

What happens if I paste something as long as a SHA-256 digest?

It converts it, provided you tell it the value is hex. A bare digest carries no 0x prefix, so auto-detection reads it as decimal and rejects the first letter it meets; either prefix it with 0x or set the source base to Hexadecimal. After that, sixty-four hex digits is a 256-bit integer, which is far beyond what ordinary floating-point arithmetic can hold, and this tool never routes a value through that type, so the decimal and octal forms come back exact rather than rounded. The binary form of such a value runs to as many as 256 digits, so expect the output panel to need scrolling.

Why did my lowercase hex input come back uppercase?

Hex input is accepted in either case, and hex output is always uppercased before it is printed. That is a display choice rather than a meaningful difference, since ff and FF are the same value, but it does mean a straight string comparison between this tool's output and a lowercase digest from somewhere else will not match until you normalise the case of one of them.

Do I have to put spaces between the bytes when converting binary back to text?

No. All whitespace is stripped first, then the remaining digits are cut into fixed-size groups, eight digits per byte for binary and two per byte for hex. A space-separated string and one long unbroken run of digits therefore behave identically. What does matter is the total length, because a digit count that is not a whole number of bytes is rejected outright rather than being padded or trimmed to fit.

Can I convert to base 32, base 36 or some other base?

No. Four bases are supported and they are fixed, namely binary, octal, decimal and hexadecimal. Those are the ones that appear in real programming and systems work, and each one has a validated digit set behind it. There is no arbitrary-base mode, so a base 36 short code or a base 32 identifier is outside what this page can read or produce.

Related tools