linkutm Logo
Glossary Term

Base64 Encoding

glossary base64 encoding featured v2

Base64 encoding is a method that converts binary data into a plain ASCII text string using a set of 64 characters. It lets binary content like images, files, or keys travel safely through systems built for text, such as email, JSON, and URLs. Base64 is encoding, not encryption: it hides nothing and anyone can decode it.

The name comes from the 64-character alphabet it uses. The standard is defined in RFC 4648.

How Base64 Encoding Works

Base64 splits binary data into 6-bit groups and maps each group to one character. Computers store data in 8-bit bytes. Base64 regroups those bits into 6-bit chunks, then assigns each chunk a character from its 64-symbol alphabet.

The process runs in three steps:

  1. Group the input into 3-byte blocks. Three bytes equal 24 bits.
  2. Split each block into four 6-bit groups. Each group has a value from 0 to 63.
  3. Map each value to a character. The result is four text characters for every three input bytes.

Because four characters represent three bytes, Base64 output is about 33% larger than the original. When the input length is not a multiple of three, Base64 adds one or two = characters as padding.

echo -n "Hi" | base64
SGk=

The Base64 Alphabet

The standard alphabet has 64 symbols plus a padding character. It breaks down as follows:

  • A to Z (26 characters)
  • a to z (26 characters)
  • 0 to 9 (10 characters)
  • + and / (2 characters)
  • = used only for padding, not for data

These characters are safe in most text contexts. The +, /, and = symbols cause problems in URLs, which is why a separate variant exists.

Base64 URL Encoding

Base64url is a URL-safe variant that swaps the unsafe characters. It replaces + with -, replaces / with _, and usually drops the = padding. This keeps an encoded value intact inside a URL or filename, where +, /, and = carry special meaning or get altered.

Base64url appears in JSON Web Tokens (JWTs), OAuth flows, and short link identifiers. To convert a value for safe use in a link, linkutm’s Base64 URL encoder produces the URL-safe output directly. Base64url is different from URL encoding, which uses percent signs (like %20) to escape individual reserved characters rather than re-encoding the whole value.

Common Uses of Base64

Base64 is used anywhere binary data must pass through a text-only channel. The most frequent cases include:

  • Email attachments. MIME encodes attachments in Base64 so they survive text-based mail transfer.
  • Data URIs. Small images can embed directly in HTML or CSS as data:image/png;base64,... to save a request.
  • API tokens and auth. HTTP Basic Auth and JWTs Base64-encode credentials and payloads.
  • Storing binary in JSON or XML. Formats that hold only text use Base64 to carry files or images.

Frequently Asked Questions

What is Base64 encoding?

Base64 encoding is a way to represent binary data as a text string using 64 characters. It converts bytes that text systems cannot handle into letters, digits, and a few symbols. This lets binary files travel through email, JSON, and URLs without corruption.

Is Base64 encoding the same as encryption?

No. Base64 is encoding, not encryption. It provides no security because anyone can decode the string back to the original data instantly. Never use Base64 to protect passwords or sensitive information.

How do you encode and decode Base64?

Most languages and tools include built-in functions. JavaScript uses btoa() to encode and atob() to decode. On Linux or macOS, the base64 command handles both directions. Online encoders and decoders also work for quick conversions.

Why is Base64 output larger than the input?

Base64 represents every 3 bytes of input as 4 text characters. That ratio makes the output roughly 33% larger than the original data. The size increase is the cost of fitting binary data into a safe text format.

What is the difference between Base64 and URL encoding?

Base64 converts entire binary blobs into a 64-character text string. URL encoding escapes individual unsafe characters in text using percent signs, such as %20 for a space. They solve different problems and are often used together.

Use the free Base64 URL encoder at linkutm to encode or decode URL-safe Base64 strings instantly.