Quick answer
Base64 is an encoding that writes any bytes using 64 printable characters (A–Z, a–z, 0–9, + and /), so binary data can travel through text-only channels such as JSON, email and URLs. It is not encryption: anyone can decode it. In Playxoft's Base64 tool, type text to encode it or paste Base64 to decode it; switch to File to convert images, PDFs and other files.
- Live both ways
- UTF-8 safe
- Base64url and padding
- MIME wrap at 76
- File to data URI
- Base64 to file download
- Error position
How to use the Base64 Encoder and Decoder
- 1Type or paste text into Text to encode it, or paste Base64 into Base64 to decode it. Both boxes update live as you type.
- 2Turn on URL-safe for Base64url (JWTs, URLs, file names), switch off Padding to drop the trailing = signs, or enable Wrap at 76 for MIME email.
- 3Choose File and drop any file to copy its Base64, a data URI, or a ready-made CSS or HTML snippet for images.
- 4To rebuild a file, paste Base64 or a data URI into Base64 to file, check the detected type and click Download file.
- 5If decoding fails, click Show me to jump straight to the first character that is not valid Base64.
What is Base64 encoding?
Base64 turns arbitrary bytes into plain ASCII text. It takes the input 3 bytes (24 bits) at a time, splits them into four 6-bit groups, and maps each group (a number from 0 to 63) to one character of a 64-character alphabet: A–Z, a–z, 0–9, + and /. The encoding is defined in RFC 4648.
| Input | Bytes (binary) | 6-bit groups | Base64 |
|---|---|---|---|
Man | 01001101 01100001 01101110 | 19 · 22 · 5 · 46 | TWFu |
Ma | 01001101 01100001 | 19 · 22 · 4 | TWE= |
M | 01001101 | 19 · 16 | TQ== |
When the input is not a multiple of 3 bytes, the last group is filled with zero bits and = padding brings the output to a multiple of 4 characters. Text is converted to bytes first — almost always as UTF-8 — which is why café encodes to Y2Fmw6k=: the é is the two bytes C3 A9.
Is Base64 encryption?
No. Base64 is an encoding: a reversible change of representation with no key and no secret. Anyone who sees dXNlcjpwYXNz can decode it to user:pass in a millisecond — which is exactly what an HTTP Basic Authorization header contains. Kubernetes Secrets, JWT payloads and many config files are Base64 too, and none of them are protected by it.
| Encoding (Base64) | Hashing (SHA-256) | Encryption (AES-GCM) | |
|---|---|---|---|
| Reversible? | Yes, by anyone | No | Yes, with the key |
| Needs a key? | No | No | Yes |
| Purpose | Carry bytes through text | Fingerprint and integrity | Confidentiality |
If data must stay private, encrypt it (for example AES-GCM via Web Crypto or libsodium) and then Base64-encode the ciphertext for transport. To fingerprint data, use the hash generator; to read a token's claims, use the JWT decoder.
Why is Base64 33% bigger than the original?
Every 3 bytes become 4 characters, so the encoded size is 4 × ⌈n / 3⌉ — about 4/3 of the input, or +33%. Padding adds up to two characters, MIME line breaks add two more bytes (CRLF) per 76 characters, and a data URI adds its data:<type>;base64, prefix.
| Original size | Base64 size | Overhead |
|---|---|---|
| 1 byte | 4 characters | +300% |
| 3 bytes | 4 characters | +33% |
| 1,024 bytes (1 KB) | 1,368 characters | +33.6% |
| 1,048,576 bytes (1 MB) | 1,398,104 characters | +33.3% |
That overhead is why inlining is a trade-off. A data URI saves an HTTP request, but the bytes grow by a third, cannot be cached separately and are re-downloaded with every copy of the page or stylesheet that embeds them. Inline small icons and tiny fonts; serve photos and large files as normal files.
Base64 vs Base64url: what is the difference?
Standard Base64 uses + and /, which have special meanings in URLs and file paths. Base64url (RFC 4648 §5) swaps them for - and _ and usually drops the padding.
| Variant | Characters 62 and 63 | Padding | Line length | Where you meet it |
|---|---|---|---|---|
| Standard (RFC 4648 §4) | + / | Required | None | JSON payloads, data URIs, most APIs |
| Base64url (RFC 4648 §5) | - _ | Usually omitted | None | JWTs, URL parameters, file names |
| MIME (RFC 2045) | + / | Required | 76 | Email attachments |
| PEM (RFC 7468) | + / | Required | 64 | Keys and certificates |
A classic bug: putting standard Base64 in a query string without escaping it. Form decoding turns each + into a space and the value breaks. Either use Base64url or URL-encode the value. Data URIs are the opposite case: browsers decode them with the standard alphabet only, so never use Base64url there. This decoder accepts both alphabets, with or without padding and line breaks.
How do I encode and decode Base64 in code?
Every language has a built-in. Modern browsers (Baseline since September 2025) convert bytes directly with Uint8Array.prototype.toBase64() and Uint8Array.fromBase64(), including the URL-safe alphabet. The one trap in older code is btoa(), which only accepts Latin-1 and throws on emoji or most non-English text, so convert to UTF-8 bytes first:
// JavaScript (modern browsers): bytes in, Base64 out
const bytes = new TextEncoder().encode("Hello, 世界");
bytes.toBase64(); // "SGVsbG8sIOS4lueVjA=="
bytes.toBase64({ alphabet: "base64url", omitPadding: true });
new TextDecoder().decode(Uint8Array.fromBase64("SGVsbG8sIOS4lueVjA=="));
// JavaScript (older browsers): UTF-8 safe btoa
const b64 = btoa(String.fromCharCode(...bytes)); // "SGVsbG8sIOS4lueVjA=="
const text = new TextDecoder().decode(Uint8Array.from(atob(b64), (c) => c.charCodeAt(0)));
// Node.js
Buffer.from("Hello, 世界").toString("base64"); // standard
Buffer.from("Hello, 世界").toString("base64url"); // URL-safe, no padding
# Python
import base64
base64.b64encode("Hello, 世界".encode()).decode() # standard
base64.urlsafe_b64encode(b"\xfb\xff").decode() # "-_8="
// Go
base64.StdEncoding.EncodeToString([]byte("Hello, 世界"))
base64.RawURLEncoding.EncodeToString(data) // URL-safe, no padding
// C#
Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello, 世界"));
Encoding.UTF8.GetString(Convert.FromBase64String(b64));On the command line, base64 file.png encodes (GNU base64 wraps at 76 columns; add -w 0 for one line) and base64 -d decodes. The spread-into-fromCharCode trick above is fine for short strings; for files, encode in chunks or use FileReader.readAsDataURL.
Frequently asked questions
Last updated by the Playxoft engineering team.