Nothing you open here is ever uploaded

Convert a number between bases

Enter a number, say what base it is in and what base you want. Anything from base 2 to base 36 works, negatives are kept, and prefixes like 0x are accepted and ignored. The conversion uses exact integer arithmetic rather than ordinary numbers, which matters more than it sounds: past about 9 quadrillion, JavaScript numbers lose precision, and a 64-bit hex identifier converts to a decimal that looks right and is wrong.

This page loads no libraries at all — the work is done by the browser itself. Your file is read on your own machine and never sent anywhere — open your browser's network tab and watch while you use it.

Questions

Why does exact arithmetic matter?

Because the failure is silent. Ordinary numbers in a browser are exact only up to about nine quadrillion; beyond that the last digits are approximated. Convert a full 64-bit hex value the naive way and you get 18446744073709552000 instead of 18446744073709551615 — a plausible number, off by 385, with nothing to warn you. Here the conversion uses exact integers, so what comes out is what went in.

Which bases can I use?

Any base from 2 to 36, in either direction. Digits run 0 to 9 and then a to z, so base 16 uses 0-f and base 36 uses the whole alphabet. Letter case does not matter on the way in.

What happens if a digit does not belong to the base?

You are told which character is wrong and which digits that base actually allows. It would be easy to skip the bad character and return a number anyway, but that number would be quietly wrong — the same class of mistake as rounding, just faster to notice if you happen to check.

Are prefixes and separators accepted?

Yes. A leading 0x, 0b or 0o is stripped, and spaces or underscores used as digit separators are ignored, so 1010_1111 and 0xFF both work. Negative values keep their sign.

Other text & code tools

Everything here is free and works the same way — in your browser.