Base64 Encoder & Decoder — Text, Files & Images
Encode text, files and images to Base64, or decode Base64 back to text or a downloadable file. Supports standard and URL-safe (base64url, RFC 4648), optional padding, MIME 76-char line wrapping, UTF-8/ASCII/UTF-16 charsets, and ready-to-paste data URI snippets for HTML, CSS and Markdown. 100% client-side.
All the ways you can use this Base64 tool
Every common Base64 workflow — encode, decode, transport binary data, and embed assets — in one place.
Encode any string — emoji, accents, CJK — using UTF-8, ASCII or UTF-16LE.
Decode a Base64 string back to readable text with automatic whitespace stripping.
Drop any file (image, PDF, font, zip) and get the full Base64 payload.
Paste a Base64 string and download the original binary file.
Generate data:image/png;base64,… URIs with the correct MIME type auto-detected.
Paste-ready <img src="data:…"> — inline images without hitting the network.
Full background-image: url("data:…") for icons and sprites.
 for README files and static docs.
RFC 4648 §4 alphabet with + and / — what most libraries emit by default.
RFC 4648 §5 variant with - and _ — safe in URLs, filenames, cookies and JWT.
Keep or drop trailing = — required for JWT, optional for plain transport.
Break output every 76 characters for email headers and quoted-printable transport.
64-character lines used by PEM certificates, public/private keys and old MIME.
Pick the exact text encoding before Base64 — essential for cross-language interop.
Decode survives line breaks, tabs, and stray spaces copy-pasted from emails or HTML.
See input size, output size, and the ~33% Base64 overhead in real time.
One click moves the output back into the input — chain encode/decode without copy-paste.
All work happens in your browser. Safe for secrets-adjacent work, client files, and offline use.
What is Base64 encoding?
Base64 is a binary-to-text encoding scheme: it takes any sequence of bytes and represents it using only 64 printable ASCII characters — A–Z, a–z, 0–9, plus two symbols (+ and /). Trailing = signs pad the output to a multiple of four characters.
The trick is that every 3 bytes of input become exactly 4 output characters, so binary data — an image, a PDF, a cryptographic signature — can travel safely through text-only channels: JSON, XML, email bodies, HTTP headers, URL parameters, HTML attributes, environment variables. The cost is a predictable ~33% size overhead.
Base64 is standardised in RFC 4648. The same RFC defines a URL-safe variant, base64url, that swaps +// for -/_ so the output survives URLs, filenames and cookies without percent-encoding.
Base64 variants at a glance
| Variant | Alphabet | Padding | Line wrap | Where you see it |
|---|---|---|---|---|
| Standard (RFC 4648 §4) | A-Z a-z 0-9 + / | Required (=) | None | btoa(), most language APIs |
| URL-safe (RFC 4648 §5) | A-Z a-z 0-9 - _ | Optional | None | JWT, OAuth, URL params, filenames |
| MIME (RFC 2045) | A-Z a-z 0-9 + / | Required | Every 76 chars | Email attachments |
| PEM (RFC 7468) | A-Z a-z 0-9 + / | Required | Every 64 chars | X.509 certs, SSH/PGP keys |
When to use Base64 (and when not to)
✅ Good uses
- Embedding small images and icons inline in HTML or CSS (avoids an extra HTTP request).
- Sending binary data inside JSON or XML APIs.
- Encoding signatures, keys and tokens in JWT, OAuth 2.0 and OpenID Connect.
- Attaching files to email (MIME).
- Storing binary blobs in text-only configuration files or environment variables.
- Safe inline transport of binary data in URL query strings (with URL-safe Base64).
⚠️ Bad uses
- Hiding secrets. Base64 is trivially reversible — not encryption. Never "protect" tokens, passwords or PII with it.
- Large images on critical pages. Inline data URIs bloat HTML and bypass CDN caching; prefer real URLs >~5 KB.
- Hashing / fingerprinting. Base64 preserves the content 1:1. Use SHA-256 / BLAKE2 instead.
- Compression. Base64 always inflates size by 33%.
- Database primary keys. Prefer UUIDs or auto-increment IDs for clarity and indexing.
Base64 in your language of choice
import base64
# Encode
b64 = base64.b64encode(b"Hello, Bitsfolio!").decode()
# URL-safe, no padding
b64url = base64.urlsafe_b64encode(b"data").rstrip(b"=").decode()
# Decode
raw = base64.b64decode(b64)
// Encode
const b64 = Buffer.from("Hello, Bitsfolio!").toString("base64");
// URL-safe
const b64url = Buffer.from("data").toString("base64url");
// Decode
const raw = Buffer.from(b64, "base64").toString();
// Unicode-safe encode
const b64 = btoa(
String.fromCharCode(...new TextEncoder().encode("héllo"))
);
// Unicode-safe decode
const txt = new TextDecoder().decode(
Uint8Array.from(atob(b64), c => c.charCodeAt(0))
);
# Encode
echo -n "Hello, Bitsfolio!" | base64
# Decode
echo "SGVsbG8sIEJpdHNmb2xpbyE=" | base64 -d
# URL-safe (GNU coreutils)
base64 -w 0 file.png | tr '+/' '-_' | tr -d '='
$b64 = base64_encode("Hello, Bitsfolio!");
$raw = base64_decode($b64);
// URL-safe
$b64url = rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
import "encoding/base64"
b64 := base64.StdEncoding.EncodeToString([]byte("Hello"))
raw, _ := base64.StdEncoding.DecodeString(b64)
// URL-safe, no padding
b64url := base64.RawURLEncoding.EncodeToString(data)
Who this Base64 tool is for
.env values, MIME email attachments, PEM keys.Frequently asked questions
What is Base64 encoding?
A scheme that represents any sequence of bytes using 64 printable ASCII characters so binary data can travel through text-only channels like JSON, HTML, URLs and email.
Is Base64 secure? Does it encrypt my data?
No. Base64 is an encoding, not encryption — anyone can decode it. Don't rely on it to protect secrets. Use proper cryptography (AES-GCM, TLS, age, PGP) for confidentiality.
What is URL-safe Base64 (base64url)?
A variant defined in RFC 4648 §5 that replaces + with - and / with _, and typically drops = padding. Used by JWT, OAuth, and anywhere Base64 needs to survive URLs, filenames or cookies.
Does this tool upload my files or text?
No. All encoding and decoding runs in your browser with the FileReader, TextEncoder and TextDecoder APIs. Nothing leaves your device.
Can I Base64-encode images for CSS or Markdown?
Yes — switch to File → Base64, drop an image, and copy the generated Data URI, HTML <img>, CSS background-image, or Markdown snippet.
Why is the output 33% larger?
Base64 maps every 3 input bytes to 4 output characters, so expect ~133% of the input size, plus a handful of padding and line-break bytes. This is the expected trade for being text-safe.
Can I decode a Base64 string with line breaks or spaces?
Yes. The decoder strips all whitespace automatically, accepts both standard and URL-safe alphabets, and tolerates missing padding.
What's the maximum file size I can encode?
There's no hard limit set by the tool, but because everything runs in memory in the browser, files up to a few megabytes work smoothly. Very large files (>50 MB) may freeze the tab.