Base64 Encoder / Decoder

Base64 Encoding: What It Is and When to Use It

๐Ÿ“… April 2026 โฑ 6 min read โœ๏ธ ToolsBox

You have probably seen strings like SGVsbG8gV29ybGQ= in code or API responses and wondered what they are. That is Base64 โ€” a way of representing binary data using only 64 printable text characters. This guide explains what it is, why it was invented, where you encounter it in the real world, and the critical difference between encoding and encryption.

What Is Base64?

Base64 is an encoding scheme that converts binary data into a string of printable ASCII characters. It uses a set of 64 characters: uppercase letters Aโ€“Z (26), lowercase letters aโ€“z (26), digits 0โ€“9 (10), and the symbols + and / (2). The = sign is used as padding at the end.

The name "Base64" refers to the 64 characters in its alphabet โ€” similar to how "Base10" refers to our everyday decimal number system with digits 0โ€“9, or "Base16" (hexadecimal) uses digits 0โ€“9 and letters Aโ€“F.

Why Does Base64 Exist?

Many older internet protocols โ€” email in particular โ€” were designed to transmit only plain text. Binary data (like images, PDFs and executables) contains byte values that some systems interpret as control characters, line endings or other special instructions. Sending raw binary through these channels causes corruption or data loss.

Base64 solves this by converting every binary byte into a combination of safe, printable characters that survive transmission through text-only systems without modification. This is why email attachments work โ€” your PDF is Base64-encoded before being sent, then decoded by the recipient's email client.

How Base64 Encoding Works

At a high level, the algorithm takes every three bytes of input (24 bits) and converts them into four Base64 characters (6 bits each). This is why Base64-encoded data is always about 33% larger than the original โ€” four characters replace three bytes.

For example, encoding the text Man:

  • ASCII bytes: 77 97 110
  • Binary: 01001101 01100001 01101110
  • Split into 6-bit groups: 010011 010110 000101 101110
  • Base64 characters: T W F u
  • Result: TWFu

If the input is not divisible by 3, = padding characters are added at the end to complete the last 4-character block.

Common Use Cases

Email Attachments (MIME)

The MIME standard for email encodes all binary attachments (images, PDFs, Word documents) in Base64 before embedding them in an email message. Your email client decodes them automatically when you download or open an attachment.

Embedding Images in HTML and CSS

Instead of linking to an external image file, you can embed the image directly in your HTML or CSS as a Base64 data URI:

<img src="data:image/png;base64,iVBORw0KGgo...">

This eliminates the HTTP request for the image file, which can be useful for small icons, logos or email templates where you cannot reference external files. The tradeoff is that the HTML/CSS file becomes larger and the image cannot be cached separately.

Use the Image to Base64 converter to get the ready-to-paste code for your images.

JWT (JSON Web Tokens)

JWTs โ€” the authentication tokens used in most modern web applications โ€” consist of three Base64url-encoded sections separated by dots: header, payload and signature.

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.SflK...

The first two sections (header and payload) are simply Base64-encoded JSON โ€” anyone can decode them. The signature section verifies the token has not been tampered with. This is why you should never put sensitive information in a JWT payload without additional encryption.

HTTP Basic Authentication

When a server requests HTTP Basic Authentication, the browser encodes your username and password as username:password in Base64 and sends it in the request header:

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

This is why HTTPS is mandatory when using Basic Auth โ€” without it, anyone intercepting the traffic can decode the credentials instantly.

Base64 Is NOT Encryption

This is the most important thing to understand. Base64 is a reversible encoding. Anyone with a Base64 string and a decoder (which is one line of code in any language) can get the original data back immediately. There is no key, no password, no security.

Do not use Base64 to:

  • Hide passwords or API keys in code.
  • "Obfuscate" sensitive data in a URL or database.
  • Protect private information from users.

For actual security, use proper encryption (AES, RSA) or secure hashing (bcrypt, Argon2 for passwords).

Encode and Decode Online

The quickest way to encode or decode Base64 text is the ToolsBox Base64 Encoder / Decoder. Paste your text and click Encode or Decode โ€” it handles Unicode and emoji correctly with full UTF-8 support.

For encoding image files, use the Image to Base64 converter โ€” it generates a ready-to-paste <img> tag and CSS background-image snippet.

Encode or decode Base64 instantly โ€” free

Full Unicode support. Runs in your browser, nothing is uploaded or stored.
Open Base64 Encoder โ†’

Frequently Asked Questions

What is Base64 used for?

Transmitting binary data (images, files, certificates) through systems that only handle text. Common uses: embedding images in HTML as data URIs, email attachments (MIME), JWT token encoding and HTTP Basic Authentication headers.

Is Base64 the same as encryption?

No. Base64 is encoding, not encryption. Anyone with the encoded string can decode it instantly. It provides zero security. Never use Base64 to hide sensitive data โ€” use proper encryption instead.

How much does Base64 increase file size?

By approximately 33%. Every three bytes of input become four Base64 characters. A 100 KB image becomes roughly 133 KB when Base64-encoded.

How do I encode text to Base64 online?

Paste your text into the ToolsBox Base64 Encoder and click Encode. For image files, use the Image to Base64 converter. Both run entirely in your browser with no uploads.

โ† Back to Blog  |  Related tools: Base64 Encoder ยท Image to Base64