Skip to content

Bidirectional Base Converter - Decimal, Hex, Base32, Base64

Convert numbers between decimal and Base16 (hexadecimal), Base32, or Base64 in either direction. RFC 4648 encodings, with a hint naming a pasted 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. It avoids letters and numbers that look alike, such as 0 and O, which makes it easier to read aloud or type by hand.
  • Base64. Uses 64 symbols: Aโ€“Z, aโ€“z, 0โ€“9, +, and /, also defined by RFC 4648. Each character stores 6 bits. It is the standard way to embed 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, then pick that base from the dropdown beside it. The tool checks the characters against the alphabet for that base, reverses the steps above, and shows the decimal value. Decoding FF as Base16 gives 255.

The tool also names the base a pasted value appears to use. That name is a hint only. The dropdown still decides how the value is read, because the Base16 alphabet is part of the Base32 alphabet and a short string such as ABCD is a legal value in both.

Base16 input can mix upper and lower case; the tool treats ff and FF the same way. An odd number of hex digits is read by place value, with a leading zero assumed, so 1F4 and 01F4 both give 500. Base32 input must be typed in upper case: the tool's decoder does not accept lower-case Base32 letters and will report an error if it sees them. Base64 treats upper and lower case letters as different symbols, as the format requires, so case must be typed exactly as shown.

Some strings can never come out of an encoder, and the tool rejects those instead of guessing. RFC 4648 builds Base64 in groups of 4 characters and Base32 in groups of 8. Ignoring any = padding, a Base64 string 1 character past a multiple of 4, or a Base32 string 1, 3, or 6 characters past a multiple of 8, holds no complete byte. Such an input gives an error rather than a number.

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 a web browser's JavaScript engine can represent exactly. 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.

The limit applies in both directions. An encoded string that stands for a larger number, such as the Base16 value 20000000000000 (which is 2^53), is rejected instead of being rounded. Fractions are rejected too: the encodings describe whole bytes, so 1.5 produces an error rather than a rounded result.

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, some file-sharing systems, and other identifiers meant to be read aloud or typed by hand.
  • 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? The Base32 alphabet is defined with upper-case letters. This tool's decoder only accepts upper-case Base32 input; lower-case letters will produce an error.

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.

Why does the tool reject some strings that look like valid Base64? Base64 is written in groups of 4 characters, so a value whose length is 1 more than a multiple of 4 encodes no complete byte. No encoder can produce it, so the tool reports an error instead of returning a number.

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.