Base64 Encoder
Encode text to Base64 in your browser. For inlining SVGs in CSS, building Basic-Auth headers, or packing binary data into URL-safe ASCII.
About Base64 Encode
Base64 encoding turns arbitrary bytes into a 64-character printable ASCII alphabet (A–Z, a–z, 0–9, +, /) plus the padding character =. Every 3 input bytes become 4 output characters — a fixed 4/3 expansion plus up to two padding bytes at the end. This encoder runs entirely in your browser via the native btoa API (with a UTF-8-aware wrapper for non-ASCII input), so secrets, tokens, and PII never leave the page. Typical encoding uses: inlining a small SVG or PNG directly into a CSS `background-image: url(data:image/svg+xml;base64,...)` rule to eliminate an HTTP round-trip for a tiny asset; composing HTTP Basic-Auth headers from a "user:password" string; encoding a JWT header or payload segment before signing; embedding a file attachment in a JSON API body where binary would need a separate multipart upload; packing a binary blob into a URL query parameter or cookie value. When not to use Base64: for any payload over a few hundred KB inside a JSON body — the 33% size expansion plus JSON string escaping makes it slow to parse and wasteful to transport. Use multipart/form-data or a direct binary upload instead. Never use Base64 as "encryption" — it's a 1:1 reversible encoding anyone can decode. The output is "printable ASCII dressed up to look secure", not a cipher.
Features
- Encode text to Base64 format instantly
- Decode Base64 strings back to plain text
- Handle UTF-8 characters correctly
- Copy encoded or decoded output to clipboard
How to Use
- Paste your text or Base64 string into the input field
- Select "Encode" or "Decode" mode
- View the converted result instantly
- Copy the output using the copy button
Frequently Asked Questions
Does Base64 encoding handle UTF-8 correctly?
Yes — the encoder first converts your input to UTF-8 bytes (via TextEncoder), then Base64-encodes those bytes. Emoji, accented characters, and non-Latin scripts round-trip cleanly. Naive btoa("Ü") would throw; this tool handles it automatically.
Why is the output 33% longer than the input?
Base64 represents every 3 bytes (24 bits) of input as 4 printable ASCII characters (24 bits spread across 4 × 6-bit symbols). That's a fixed 4/3 = 33% expansion, plus up to 2 "=" padding characters at the end. It's the cost of translating an 8-bit byte alphabet into a 6-bit printable alphabet.
When should I use base64url instead of standard Base64?
Anywhere URL-unsafe characters would break things: URL path segments, query parameters, cookie values, JWT parts, filenames. base64url replaces + with -, / with _, and usually drops the = padding. The underlying bytes are the same; the output alphabet is the difference.
Can I encode a binary file here?
Short binary blobs pasted as text work, but for actual files (images, PDFs, binary data) use the Image-to-Base64 tool which accepts file uploads via FileReader. For multi-megabyte files, a CLI like `base64 < file.bin` is faster and doesn't tie up your browser.