Base64 Encoder/Decoder

Encode text to Base64 or decode Base64 back to text, with support for standard and URL-safe encoding

Last updated: 2026-07-16

Encode
Decode
Standard

Base64 is a binary-to-text encoding scheme that represents any data (text, images, files) as a string of printable ASCII characters. It's not encryption -- anyone can decode Base64 instantly -- it exists so binary data can travel safely through systems that only handle text, like embedding images in CSS/HTML, attaching files to emails (MIME), or passing data in JSON/URLs. Our free tool encodes text to Base64 or decodes Base64 back to text, in both the standard and URL-safe variants, right in your browser.

How Base64 Encoding Works

O(n)
3 bytes (24 bits)    4 characters (4×6 bits)3 \text{ bytes (24 bits)} \;\rightarrow\; 4 \text{ characters (4} \times \text{6 bits)}

input is grouped into 3-byte (24-bit) chunks, each split into four 6-bit values

Each 6-bit value (0-63) maps to one character in the Base64 alphabet: A-Z, a-z, 0-9, plus two more symbols. Standard Base64 uses + and / for those last two symbols, with = padding at the end so the output length is always a multiple of 4. URL-safe Base64 (RFC 4648 §5) swaps in - and _ instead, and conventionally drops the padding, so the result can be used directly in a URL or filename without escaping.

Example: the text "hello" (5 bytes) becomes "aGVsbG8=" (8 characters) -- Base64 output is always about 33% larger than the input, since 3 bytes of input always become 4 characters of output regardless of what those bytes are.

Use Cases

Embedding Images in CSS or HTML

Data URIs (data:image/png;base64,...) let you inline small images directly in a stylesheet or HTML file, avoiding an extra HTTP request.

Email Attachments (MIME)

Email protocols are text-only, so attachments are Base64-encoded to travel safely through mail servers as part of a MIME message.

API Authentication Headers

HTTP Basic Auth encodes "username:password" as Base64 in the Authorization header -- not secure on its own, but part of the standard.

Storing Binary Data in JSON

JSON has no native binary type, so binary data (files, images, keys) is commonly Base64-encoded into a JSON string field.

URL-Safe Tokens

The URL-safe variant is used for things like JWT (JSON Web Token) segments, which need to appear directly in a URL without percent-encoding.

Frequently Asked Questions

Is Base64 encryption or a security measure?

No. Base64 is an encoding, not encryption -- it has no key and anyone can decode it instantly with this tool or a single line of code. Never rely on Base64 alone to protect sensitive data like passwords or personal information.

Why does encoded output end with = signs?

Standard Base64 output length must be a multiple of 4 characters. When the input length isn't a multiple of 3 bytes, = padding characters are added at the end to fill out the last group. URL-safe Base64 conventionally omits this padding.

What's the difference between standard and URL-safe Base64?

They use the same core alphabet except for two characters: standard uses + and /, while URL-safe (RFC 4648 §5) uses - and _ instead, since + and / have special meaning in URLs. URL-safe output also typically skips the = padding.

Why is the encoded output longer than my input?

Base64 always converts every 3 bytes of input into 4 characters of output, regardless of content, so encoded data is always about 33% larger than the original.

Does this tool work with emoji and non-English text?

Yes. Input is read as UTF-8 text before encoding, so accented characters, emoji, and non-Latin scripts round-trip correctly through encode and decode.

Why did decoding fail with an error?

Decoding fails if the input contains characters outside the Base64 alphabet for the selected format, has broken padding, or (rarely) decodes to bytes that aren't valid UTF-8 text. Double check you've selected the right format (Standard vs. URL-safe) for the text you're decoding.

References

Ad Space (AdSense)

Related Tools