Skip to main content
K
KnowKit

Ever seen text like "SGVsbG8gV29ybGQ=" and wondered what it means?

Decode it here — and learn what Base64 encoding actually does.

Base64 Encode / Decode

Encode text to Base64 or decode Base64 back to text

What is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 ASCII characters: uppercase letters A-Z, lowercase letters a-z, digits 0-9, plus sign (+), and forward slash (/). It converts every 3 bytes of input into 4 characters of output, making it useful whenever you need to transmit binary data over channels that only support plain text, such as email, JSON, or URL parameters.

How Base64 Works

The encoding process works in four steps. First, the input text is converted to its binary representation (UTF-8 bytes). Second, the bit stream is divided into groups of 6 bits each. Third, each 6-bit value (0-63) is mapped to its corresponding character in the Base64 alphabet. Fourth, if the final group has fewer than 6 bits, padding characters (=) are added. This is why Base64 output is always approximately 33% larger than the input — 3 bytes become 4 characters.

Common Use Cases

  • Email attachments: MIME encoding uses Base64 to embed binary files in email messages
  • Data URIs in HTML/CSS: Embedding small images directly using data:image/png;base64,...
  • API authentication: HTTP Basic Auth sends base64(username:password) in the Authorization header
  • JSON Web Tokens (JWT): JWT header and payload segments are Base64URL-encoded
  • Binary data in JSON: XML or binary payloads embedded within JSON API responses

Common Mistakes

  • Confusing Base64 encoding with encryption — Base64 is easily reversible, not secure
  • Forgetting that Base64 increases data size by ~33%
  • Not handling Unicode characters — non-ASCII text needs UTF-8 encoding first

Pro Tips

  • Use Base64 for embedding small images in HTML/CSS via data URIs
  • APIs often require Base64 for binary data in JSON payloads
  • When decoding, always specify the character encoding (UTF-8)

Real-World Examples

Email attachments

Email MIME format uses Base64 to encode binary attachments

Data URIs

Embed small images directly in CSS: background: url(data:image/png;base64,...)

API authentication

HTTP Basic Auth sends credentials as Base64(user:pass)

Want to learn more?

Text Encoding Explained

Read Full Guide
On this page

About Base64

What is Base64?

Base64 turns binary data into plain text using 64 characters -- letters, digits, +, and /. Every 3 bytes of input become 4 characters of output, so encoded strings are roughly 33% larger. The = character pads the end when the input isn't a multiple of 3 bytes.

You'll see it everywhere: data URIs in HTML/CSS, JSON API payloads with binary attachments, HTTP Basic Auth headers, and email MIME encoding. If you've ever seen a string likeiVBORw0KGgo... in source code, that's Base64. It's encoding, not encryption -- anyone can decode it. If you need to protect data, use AES.

Common Use Cases

Data URIs

Embed a small image directly in HTML or CSS without a separate file:data:image/png;base64,iVBORw0KGgo.... Great for icons and tiny images, but large files will bloat your page weight.

API Payloads

Many JSON APIs can't handle raw binary. Base64 lets you send images, files, or protobufs in a text field. Email attachments work the same way -- MIME encodes binary as Base64 so it survives text-based transport.

Authentication

HTTP Basic Auth sends base64(username:password) in the Authorization header. Simple and widely supported, but only safe over HTTPS.

Frequently Asked Questions

Is Base64 the same as encryption?
No. It's a reversible encoding with zero security. Use AES-256 if you need to protect data.

Why does Base64 increase data size?
3 bytes in, 4 characters out -- that's 33% overhead from using only printable ASCII.

Can I encode non-ASCII text like Chinese or emoji?
Yes. The tool converts to UTF-8 bytes first, then encodes. Decoding reverses it.

What does "Invalid Base64 input" mean?
The string has characters outside the Base64 alphabet or wrong padding. Common cause: truncated data from copy-pasting.

This utility is provided for informational purposes only. KnowKit is not responsible for any errors in the output.

Base64 Encoder FAQ

Is Base64 encoding the same as encryption?

No. Base64 is encoding, not encryption. It is trivially reversible without any key or secret — anyone can decode it. Base64 obscures data at a glance but provides zero security. Never use Base64 to protect passwords, tokens, or any sensitive information. Use proper encryption like AES-256 instead.

Why is Base64 output larger than input?

Because 3 bytes of input (24 bits) are mapped to 4 Base64 characters (each representing 6 bits). The output is always approximately 33% larger than the input due to the expanded character space. Padding characters (=) are added when the input length is not a multiple of 3 bytes.

What's the difference between Base64 and Base64URL?

Base64URL replaces + with - and / with _, and removes the padding character (=). This makes the output URL-safe since +, /, and = have special meaning in URLs and query parameters. Base64URL is used in JWTs and other web standards where the encoded value appears in a URL.

Can Base64 encode images?

Yes. Base64 is commonly used to embed small images directly in HTML or CSS using data URIs (data:image/png;base64,...). This avoids an extra HTTP request for tiny icons or logos. However, since Base64 increases file size by 33%, it is not recommended for large images — serve them as separate files instead.

Can I encode non-ASCII text like Chinese or emoji?

Yes. The tool first converts text to UTF-8 bytes before encoding, so it handles Chinese characters, emoji, and any other Unicode text. When decoding, the UTF-8 bytes are converted back to the original string. Not all Base64 tools handle Unicode correctly — some produce garbled output.

What does 'Invalid Base64 input' mean?

The string contains characters outside the Base64 alphabet (A-Z, a-z, 0-9, +, /) or has incorrect padding. The most common cause is truncated data from copy-pasting. Make sure you copied the entire Base64 string including any trailing = padding characters.

Is Base64 safe to use in URLs?

Standard Base64 uses +, /, and = which have special meaning in URLs. Use Base64URL encoding instead, which replaces + with -, / with _, and removes padding. Most web frameworks provide built-in Base64URL encoding/decoding functions.

How does Base64 handle binary files like PDFs or images?

Binary files are first read as raw bytes, then each byte is encoded as if it were text. The resulting Base64 string can be embedded in JSON, sent in an email, or used in a data URI. The decoding process reverses this to reconstruct the original binary file byte-for-byte.