How to use the Base64 Encoder / Decoder
- Pick a mode: Encode (text → Base64), Decode (Base64 → text), or Auto (detects from input).
- Paste into the left textbox. Processing runs automatically after 200ms.
- Toggle options as needed: URL-safe (
-_instead of+/), No padding (strip trailing=), Wrap 76 (MIME-style line wrapping). - For files, click Upload file (up to 10MB). The output is a full
data:URL ready to paste into HTML or CSS. - Copy with the Copy button or
Ctrl/⌘ + Shift + C.
What is Base64?
Base64 is a way of representing binary data using only 64 printable ASCII characters:
A–Z, a–z, 0–9, +, and /,
with = used for padding. It's defined in
RFC 4648. The
encoded output is about 33% larger than the original (every 3 bytes of input become 4 characters of output).
Base64 is not encryption. It's a reversible encoding — anyone who sees the encoded string can decode it back to the original. Use it for transport, not secrecy.
URL-safe Base64 vs standard Base64
Standard Base64 uses + and /, which have special meaning in URLs and filenames.
URL-safe Base64 (RFC 4648 §5) replaces them with - and _.
It's used in JWTs, OAuth tokens, and most modern web APIs. Use the URL-safe option whenever the output
needs to survive a URL, filename, or identifier.
Padding (=) is often omitted in URL-safe Base64 because its length information is implicit.
The No padding option strips trailing = characters. This tool re-pads
automatically when decoding, so unpadded input works fine.
When to use Base64 (and when not to)
Good use cases:
- Embedding small images/fonts directly in HTML or CSS via
data:URLs (saves an HTTP request). - Carrying binary payloads over text-only transports (email bodies, JSON fields, URL parameters).
- Encoding JWTs and API signatures in HTTP headers.
- Quick round-trip obfuscation when human-readability matters but secrecy does not (copy-paste friendly).
Bad use cases:
- Never use Base64 for secrecy. It's trivially reversible. For secrecy, use AES or similar.
- Large images in HTML. Beyond ~10KB, a normal
<img>with caching is faster. - Storing passwords. Ever. (Use bcrypt/argon2 instead — see the hash generator when it ships.)
- Binary-heavy data. If you control both ends, raw bytes or a binary protocol is ~33% smaller.
Common errors and what they mean
"Invalid character in Base64 string"
Your input contains a character outside the Base64 alphabet. The usual suspects: a stray space, a newline
in the middle, a URL-safe string being decoded in standard mode (switch URL-safe on),
or unescaped + characters that became spaces during URL transport.
"Length is not a multiple of 4"
Base64 must be padded to a multiple of 4 characters. This tool re-pads automatically, but if you see the
error elsewhere (e.g., in Python's base64.b64decode), add = until the length
is a multiple of 4, or use urlsafe_b64decode variants that tolerate missing padding.
Garbled decoded output
Usually a character-encoding mismatch. This tool decodes as UTF-8. If your input was originally in Latin-1, Windows-1252, or another encoding, you'll get mojibake. Copy the decoded bytes into a hex viewer or re-encode the original source as UTF-8 before encoding.
UTF-8 vs Latin-1 gotcha
The browser's built-in btoa() and atob() only work on Latin-1 (single-byte)
strings and will throw on characters outside that range — including most emoji, CJK characters, and
accented Latin beyond ISO-8859-1. This tool uses TextEncoder/TextDecoder for
proper UTF-8 support, so strings like "🦊 résumé 日本" encode and decode correctly.
Frequently asked questions
Is the Base64 encoder really client-side?
Yes. All encoding, decoding, and file processing happens in JavaScript running in your browser. You can verify this by opening DevTools → Network and watching: no request is sent when you click Encode or upload a file. You can also disconnect from the internet after the page loads and the tool keeps working.
Can I encode a whole file to Base64?
Yes — click Upload file. The output is a full data: URL (including the
detected MIME type), which you can paste directly into <img src="..."> or
url(...) in CSS. File size cap is 10MB to keep the UI responsive; beyond that, browsers
get slow and most real use cases want a proper asset URL anyway.
How do I convert Base64 back into a downloadable file?
Paste the Base64 (or full data URL) into the input, select Decode, and the decoded
bytes will be interpreted as UTF-8 text. To reconstruct a binary file, use a language-native base64
decoder (Python base64.b64decode, Node Buffer.from(s, 'base64')) and write
the bytes to disk. A browser-native "Download decoded file" is on the roadmap.
Does this tool support Base64 URL-safe JWT tokens?
Yes — enable URL-safe and No padding, then decode each of the three dot-separated sections of a JWT. For a dedicated token-parsing experience with algorithm info and claim pretty-printing, see the upcoming JWT Decoder.
Why is the Base64 output 33% larger than the input?
Base64 encodes every 3 bytes (24 bits) of input as 4 characters (32 bits — one 6-bit value per char). That's a fixed 4/3 expansion, plus up to 2 padding characters at the end. If size matters (SMS, QR codes), consider Base85 or Base91 — or better, don't encode in the first place.
Is this tool RFC 4648 compliant?
Yes. Both the standard alphabet (§4) and the URL-safe alphabet (§5) are implemented faithfully. Padding is preserved by default and stripped only when you ask for it. Line wrapping uses the MIME standard 76-character width (§3.1) when enabled.
Related tools
- JSON Formatter — Format, validate, and beautify JSON online. 100% client-side — your data never leaves your browser.
- URL Encoder / Decoder — Percent-encode and decode URLs per RFC 3986.
- JWT Decoder — Decode and inspect JSON Web Tokens. Local-only — tokens never leave your browser.
- UUID Generator — Generate UUID v4 and v7 identifiers in bulk.
- Hash Generator — Generate MD5, SHA-1, SHA-256, and SHA-512 hashes client-side.
Further reading
Pillar
Part of Encoding & Crypto — Base64, URL, JWT, hashes, UUID, QR, password.
Written and maintained by Mian Ali Khalid. Last updated 2026-04-25.