Hex to decimal, digit by digit.
Convert hex to decimal, decimal to binary or any base from 2 to 36 in your browser, exact for numbers of any length. How bases work; nothing uploaded.
By Suraj Kumar4 min read
A number is the same number in any base; only its digits change. Hex to decimal writes whole numbers in binary, octal, decimal, hexadecimal or any base up to 36, and keeps every digit exact.
Each place is worth more than the last.
In decimal each place is worth ten times the one to its right. In hexadecimal it is sixteen times, with A to F standing for 10 to 15, so FF is 15 × 16 + 15, which is 255. In binary it is two times, so 2026 is 11111101010.
Type a number, one a line, and choose From and To on the step: binary, octal, decimal, hexadecimal, or any base from 2 to 36 under them, where Z stands for 35. Letters can be capitals or small, and the result is written in the case you choose.
0x, 0b and 0o say the base.
Code often writes the base in front: 0x for hexadecimal, 0b for binary and 0o for octal. Auto reads them as Python's int(text, 0) does, and a number with no prefix as decimal; the note says which base each was read in.
With a base chosen, a prefix is read only when it is that base's own, as Python's int(text, base) does. In hexadecimal, 0b1 is the number B1, 177, because b is a hex digit. Spaces, commas, apostrophes and underscores between digits are passed over, so 1,000,000 and 1_000_000 both read, and the note says so.
Every digit, however long.
Many converters lose digits past 9,007,199,254,740,991, the largest whole number a JavaScript number holds exactly: FFFFFFFFFFFFFFFF comes out as 18446744073709552000. Here numbers are BigInts, so it is 18446744073709551615, and a 128-bit number such as FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF gives all 39 of its decimal digits.
A negative number keeps its minus sign: -255 is -FF. It is not written as two's complement, which depends on how many bits a program keeps. Numbers of up to 100,000 digits are read; the answers were checked against Python's int() and format().
A wrong digit is named, not guessed.
A digit the base does not have stops the conversion and is named with where it is: in 1F2G read as hexadecimal, “G” at character 4. A point stops it too, since only whole numbers are converted.
To turn text into binary instead, letter by letter, use the Binary translator: it writes the bytes of what you type, so 255 there is three characters and 24 binary digits, not 11111111.
Nothing leaves your browser.
Everything is worked out on your device: what you paste or open is never sent anywhere, and nothing is kept when you leave. A share link carries what you typed after the #, which browsers never send to a server.
The same toolkit works out subnets, and Unix time as a date.
Further reading
Topics: hex to decimal · decimal to hex · decimal to binary · binary to decimal · number base converter · octal to decimal · base 36
A little less theory. A little more doing.
Try it on your own terms, with a free browser tool.
Try the tool