What Is Base64 Encoding?

Base64 is a way to represent any binary data using only 64 printable, text-safe characters — handy for moving images, files, and bytes through systems that expect plain text.

What Base64 actually does

Base64 is a binary-to-text encoding. It takes raw bytes — an image, a PDF, a cryptographic key, or just a string of characters — and rewrites them using only 64 safe characters that survive transmission through text-only channels. It is not compression and not encryption; it simply re-expresses the same data in a more portable form.

The reason it exists is historical and practical: many older protocols (email, some HTTP headers, URLs) were designed for plain ASCII text and can corrupt or choke on arbitrary bytes like null characters or control codes. Base64 sidesteps that by mapping everything to letters, digits, and a couple of symbols.

The 64-character alphabet

The standard alphabet (defined in RFC 4648) is:

  • A–Z → values 0–25
  • a–z → values 26–51
  • 0–9 → values 52–61
  • + → value 62, and / → value 63

That is 64 symbols, which is exactly why it is called Base64: each character can represent one of 64 possible values, or 6 bits of information (because 26 = 64).

How 3 bytes become 4 characters

Bytes are 8 bits each; Base64 characters are 6 bits each. The least common multiple of 8 and 6 is 24, so Base64 works in groups of 3 bytes (24 bits), which split evenly into 4 characters (4 × 6 = 24 bits). The process:

  1. Take 3 bytes and line up their 24 bits.
  2. Re-slice those 24 bits into four 6-bit chunks.
  3. Look up each chunk in the 64-character alphabet.

Worked example: encoding "Man"

Take the three ASCII characters M, a, n:

Char:     M          a          n
ASCII:    77         97         110
Bits:     01001101   01100001   01101110

Regroup into 6-bit chunks:
          010011  010110  000101  101110
Value:    19      22      5       46
Char:     T       W       F       u

Result:   "Man"  ->  "TWFu"

Three bytes in, four characters out. This is also why Base64 makes data roughly 33% larger: every 3 bytes turn into 4 characters of output.

Padding with "="

Real data is not always a multiple of 3 bytes, so Base64 pads the final group. The = sign is a marker that says "these bits were just filler, ignore them":

  • 3 bytes → 4 characters, no padding. ManTWFu
  • 2 bytes → 3 characters + one =. MaTWE=
  • 1 byte → 2 characters + two ==. MTQ==

So a Base64 string ending in = or == just means the original length was not a clean multiple of 3.

The URL-safe variant

The standard + and / characters cause problems in URLs and filenames — / looks like a path separator and + can be read as a space. The URL-safe alphabet fixes this by substituting:

  • +- (hyphen)
  • /_ (underscore)

URL-safe Base64 also commonly omits the padding =, since = is itself awkward in URLs. This variant is what you see in JSON Web Tokens (JWTs) and many web APIs.

Common use cases

  • Data URLs: embedding a small image directly in HTML or CSS, e.g. data:image/png;base64,iVBORw0KG... so no separate request is needed.
  • Embedding binary in JSON or XML: these formats are text-only, so binary fields (file contents, certificates) are carried as Base64 strings.
  • Email (MIME): attachments and non-ASCII message parts are Base64-encoded so 8-bit bytes pass safely through mail servers.
  • HTTP Basic authentication: the header sends Authorization: Basic followed by the Base64 of username:password.

Important: Base64 is not encryption

This is the single most misunderstood point. Base64 provides no security whatsoever. There is no key and no secret — anyone can decode it instantly with a single function call. HTTP Basic auth, for example, is only as safe as the HTTPS connection carrying it; the credentials themselves are trivially recoverable from the Base64 string. Never use Base64 to "hide" passwords, tokens, or sensitive data. For confidentiality you need real encryption (such as AES or TLS).

Encoding and decoding with Formatly

Formatly's Base64 Encode / Decode tool converts text or data to and from Base64 right in your browser, with proper UTF-8 support so accented letters, emoji, and other multi-byte characters round-trip correctly. Because everything runs locally and nothing is uploaded to any server, you can safely paste tokens, config snippets, or other sensitive strings while you inspect them — the data never leaves your machine.

FAQ

Is Base64 a form of encryption?

No. Base64 is an encoding, not encryption. It uses no key or secret, so anyone can reverse it instantly. Treat a Base64 string as fully readable — never use it to protect passwords or sensitive data. For real confidentiality, use encryption such as AES or transport it over HTTPS/TLS. Formatly's decoder runs entirely in your browser, so you can safely test sensitive strings without uploading them anywhere.

Why does Base64 make data about 33% bigger?

Base64 turns every 3 bytes (24 bits) of input into 4 characters (32 bits as text). That 4-to-3 ratio is a 33% increase in size, plus a little extra for padding = characters. This is the trade-off for making binary data safe to send through text-only channels like email, JSON, and URLs.

What do the "=" signs at the end of a Base64 string mean?

The = is padding. Base64 processes data in 3-byte groups, and when the input length is not a multiple of 3, padding fills the gap. A single = means the last group had 2 bytes; == means it had 1 byte. For example, Ma encodes to TWE= and M encodes to TQ==. The padding tells the decoder how many filler bits to discard.

What is URL-safe Base64 and when is it used?

URL-safe Base64 replaces the two problematic characters + and / with - and _, and usually drops the = padding. This keeps the output safe inside URLs and filenames, where / and + would otherwise be misinterpreted. It is the variant used in JSON Web Tokens (JWTs) and many web APIs.

Does Formatly's Base64 tool send my data to a server?

No. Formatly's Base64 Encode / Decode tool is 100% client-side — all processing happens locally in your browser and nothing is uploaded. It also includes full UTF-8 support, so text with accents, emoji, or other multi-byte characters encodes and decodes correctly. This makes it safe for handling tokens, credentials, or any private snippet.