Skip to main content

Guides

~6 min read

What Is Base64 Encoding?

Base64 encoding is one of those concepts that appears frequently in web development, email, and APIs but is rarely explained clearly. This is what it is, why it exists, and when you will actually need to use it.

Why Base64 exists

Computers store everything as binary data — sequences of bytes represented as numbers from 0 to 255. Many communication systems, however, were built to handle text only. Email systems, HTTP headers, and many older protocols were designed around the assumption that data is plain ASCII text. Sending raw binary through one of these systems can corrupt the data because certain byte values are interpreted as control characters.

Base64 solves this by converting binary data into a string of printable ASCII characters. Every possible byte value is represented using only 64 safe characters: A–Z, a–z, 0–9, plus (+), and slash (/). The result is larger than the original (about 33% larger), but it travels safely through any text-based system without corruption.

Where Base64 is used in practice

Base64 appears in several everyday technical contexts:

  • Email attachments: MIME encoding uses Base64 to send file attachments through email servers that were originally built for text only.
  • Data URLs in CSS and HTML: An image can be embedded directly in a stylesheet or HTML file as a Base64 string instead of a separate file reference: src="data:image/png;base64,iVBOR..."
  • HTTP Basic Authentication: Username and password are Base64-encoded before being placed in the Authorization header.
  • JSON payloads: Binary data like images or file content is encoded as Base64 when it needs to travel inside a JSON string.
  • JWTs (JSON Web Tokens): The header and payload of a JWT are Base64url-encoded (a URL-safe variant of Base64).

How to encode and decode Base64 online

To encode text or data to Base64, open the Base64 Encoder, paste your input, and copy the encoded string. The result is a block of characters that looks like random letters and numbers — for example, the word "Hello" encodes to "SGVsbG8=".

To decode a Base64 string back to readable text, open the Base64 Decoder, paste the encoded string, and read the decoded result. This is useful when inspecting JWT payloads, reading encoded API responses, or verifying what an email header contains.

Note: Base64 is encoding, not encryption. Anyone with a Base64 string and a decoder can read the original content. Do not use Base64 to hide sensitive information — use proper encryption for that.

Base64url vs standard Base64

Standard Base64 uses + and / characters, which have special meanings in URLs (+ means space, / separates path segments). Base64url is a URL-safe variant that replaces + with - and / with _. This version is used in JWTs, OAuth tokens, and any context where the encoded string appears in a URL or URL query parameter.

When decoding a JWT, the three segments separated by dots are each Base64url-encoded. The JWT Decoder on Toolbox Hub handles this automatically — paste the full token and it shows the decoded header and payload.

What Is Base64 Encoding? FAQs

Is Base64 the same as encryption?

No. Base64 is encoding — it changes the representation of data but does not hide or protect it. Anyone can decode a Base64 string without a key. Encryption requires a key and produces output that cannot be read without it. Never use Base64 alone to protect sensitive information.

Why does Base64 encoded data end with = or ==?

Base64 works on groups of 3 bytes at a time, producing 4 output characters. If the input is not divisible by 3, padding characters (=) are added to make the output length a multiple of 4. One = means the last group had 2 bytes; == means it had 1 byte.

How much larger is Base64 output than the original?

Base64 encoding increases data size by approximately 33%. Every 3 bytes of input become 4 bytes of output. This overhead is acceptable for most use cases, but very large binary files embedded as Base64 can noticeably inflate page size or payload size.

Can Base64 encode any type of data?

Yes. Base64 can encode any binary data — text, images, audio, video, or arbitrary bytes. The encoded output is always a string of printable ASCII characters regardless of what the input was.

Related tools

Ready to try it yourself? Start with the tools below or browse the full tools directory.