Skip to content

Bidirectional Base Converter - Decimal, Hex, Base32, Base64

Convert numbers between decimal and Base16 (hexadecimal), Base32, or Base64 in either direction, with automatic detection of the encoded value's base.

Bidirectional Base Converter

Convert between decimal numbers and standard base encodings (Base16/Hex, Base32, Base64). Enter a value in either field to convert.

Enter a non-negative integer (max: 9,007,199,254,740,991)

Enter an encoded value, then choose its base from the list

About Base Encodings

Base16 (Hexadecimal): Uses characters 0-9 and A-F. Each character represents 4 bits. Commonly used for color codes and memory addresses.
Base32: Uses characters A-Z and 2-7. Each character represents 5 bits. Decoding requires upper-case input; the encoder always outputs upper case.
Base64: Uses characters A-Z, a-z, 0-9, +, and /. Each character represents 6 bits. Commonly used for encoding binary data in text.
Safe Integer Limit: JavaScript can safely represent integers up to 9,007,199,254,740,991 (2^53 - 1) without precision loss.
Loading calculator...
๐Ÿ“š

Documentation

Bidirectional base converter

A base converter changes how a number is written, without changing the number itself. This tool converts a decimal number into Base16 (hexadecimal), Base32, or Base64, and it converts an encoded value back into decimal. It also detects which of the three encodings a pasted value uses.

What a number base is

A number base, also called a radix, is the count of different symbols a number system uses for a single digit. Decimal is base 10 and uses the digits 0 to 9. Computers often store numbers in other bases because those bases pack the same value into fewer characters, or because the character set is safe to send through text-only systems like email or a URL.

This tool works with three such bases:

  • Base16 (hexadecimal). Uses the 16 symbols 0โ€“9 and Aโ€“F. Each character stores 4 bits. Common in color codes, memory addresses, and hash values.
  • Base32. Uses the 32 symbols Aโ€“Z and 2โ€“7, defined by the internet standard RFC 4648. Each character stores 5 bits. The standard designs it for systems that need a case-insensitive alphabet.
  • Base64. Uses 64 symbols: Aโ€“Z, aโ€“z, 0โ€“9, +, and /, also defined by RFC 4648. Each character stores 6 bits. It is widely used to carry binary data inside text, such as an email attachment or a JSON field.

How to convert a decimal number to Base16, Base32, or Base64

The tool first breaks the decimal number into bytes, groups of 8 bits, written in big-endian order (most significant byte first). It then reads those bits off in groups sized for the target base: 4 bits at a time for Base16, 5 bits at a time for Base32, or 6 bits at a time for Base64. Each group of bits is looked up in that base's symbol table to produce one output character.

Because Base32 and Base64 read bits in groups of 5 or 6, the last group in a number often does not land on an 8-bit byte boundary. The tool pads the leftover bits with zeros and, for Base32 and Base64, adds = characters at the end so the output length is always a multiple of 8 characters (Base32) or 4 characters (Base64).

Base16 always uses a whole number of 2-character pairs, one pair per byte. A value that would need an odd number of hex digits gets a leading zero instead, so the string always represents a whole number of bytes.

Base16 formula and example

Each byte becomes exactly two hex digits, worth 16 times the first digit plus the second:

byte value = (first digit) ร— 16 + (second digit)

Example: 255 in decimal. 255 fits in one byte. 255 รท 16 = 15 remainder 15, and 15 is written as F, so 255 becomes FF. This is why the color code #FFFFFF is white: three bytes, each at their highest value.

Example: 1000 in decimal. 1000 needs two bytes: 1000 = 3 ร— 256 + 232. The first byte, 3, becomes 03. The second byte, 232, is 14 ร— 16 + 8, which becomes E8. Read together, 1000 in Base16 is 03E8, not 3E8. Hex output is always padded to whole bytes, so a value under 16 in the top byte still gets a leading zero.

Base32 and Base64 examples

Using the same two numbers as above:

DecimalBase16Base32Base64
255FF74======/w==
100003E8APUA====A+g=

How to convert an encoded value back to decimal

Paste a Base16, Base32, or Base64 string into the encoded field and choose its base. The tool decodes the string using the selected base and reverses the steps above to recover the original number. It also shows which of the three bases the characters appear to belong to, as a hint. For example, decoding FF as Base16 gives 255.

Base16 input can mix upper and lower case; the tool treats ff and FF the same way. Base32 input is case-insensitive too, as RFC 4648 describes the encoding: the tool accepts apua==== and APUA==== alike. Output is always upper case. Base64 treats upper and lower case letters as different symbols, as the format requires, so case must be typed exactly as shown.

Range limits

The largest number the tool accepts is 9,007,199,254,740,991, equal to 2^53 โˆ’ 1. This is the largest whole number JavaScript can represent safely. Above that limit, some integers can no longer be stored precisely, so the tool reports an error rather than silently returning a wrong digit. Zero and any whole number up to that limit are accepted; the number does not need to be positive, only non-negative.

Where each encoding is used

  • Base16 appears in CSS and HTML color values, MAC and IPv6 addresses, and the hash values used to check that a file has not been altered.
  • Base32 appears in two-factor authentication setup keys and other identifiers that must survive systems which ignore letter case.
  • Base64 appears in data: URIs, email attachments, and web tokens such as JWTs, wherever binary data needs to travel through a system built for text.

Converting between these encodings never changes the underlying number. It only changes how many characters are needed to write it down, and which systems can carry that text safely.

Frequently asked questions

What is the difference between Base16, Base32, and Base64? They differ in how many symbols each character can represent: 16, 32, or 64. More symbols per character means a shorter encoded string for the same number, at the cost of a larger alphabet to read.

Why does 1000 encode to 03E8 instead of 3E8 in Base16? Hexadecimal output is padded to a whole number of bytes, two hex digits per byte. 1000 needs two bytes, so the result always has four hex digits, even though the leading digit is zero.

Is Base32 case-insensitive? Yes. The standard defines the Base32 alphabet with upper-case letters and describes the encoding as case-insensitive. This tool's decoder accepts upper-case, lower-case or mixed-case Base32 input.

What is the largest number the converter can handle? 9,007,199,254,740,991, which is 2^53 โˆ’ 1. This is the limit of exact integer precision in JavaScript, the language the tool runs in.

Can I convert a negative number? No. The tool only accepts whole numbers of zero or greater.

Does converting a number between bases change its value? No. It changes only the written form. 255, FF, 74======, and /w== all represent the identical number.

References

  1. Internet Engineering Task Force. RFC 4648: The Base16, Base32, and Base64 Data Encodings. RFC 4648 โ€” Base16, Base32, and Base64 alphabets; 4, 5, and 6 bits per character; zero-bit filling and = padding; Base16 and Base32 described as case-insensitive.
  2. MDN Web Docs. Number.MAX_SAFE_INTEGER. Number.MAX_SAFE_INTEGER โ€” the largest safe integer in JavaScript is 2^53 โˆ’ 1, or 9,007,199,254,740,991.