Guide
Base64 encoding and decoding explained, with the pitfalls
Base64 is how binary data travels through channels built for text: email attachments, JSON payloads, data URLs in HTML and CSS, HTTP Basic authentication headers, tokens and configuration files. It turns any bytes into a string of 64 safe characters (A–Z, a–z, 0–9, + and /) and back again. This tool encodes and decodes text and files in your browser.
Encoding text
- Choose Encode.
- Type or paste the text. It’s converted to bytes as UTF-8, so accents, other scripts and emoji survive the round trip.
- Optionally switch on URL-safe for tokens, URLs and file names.
- Copy the Base64.
For example, Hello, world! becomes SGVsbG8sIHdvcmxkIQ==.
Decoding
Choose Decode and paste the Base64. The decoder is forgiving:
- Standard and URL-safe alphabets are both accepted.
- Missing padding (the trailing
=) is added automatically. - Line breaks and spaces, common in email and PEM files, are ignored.
- A data URL prefix such as
data:image/png;base64,is stripped.
If the decoded bytes are readable UTF-8 text, you see the text. If not, the result is binary data, such as an image, a PDF or a compressed file, and you can download it with the File button.
Invalid input produces a specific error: characters outside the Base64 alphabet, or a length that can’t be valid.
Encoding a file
Drop any file into Encode a file to get its Base64. Copy it as plain Base64 or as a data URL, ready to paste into HTML or CSS. The tool shows how long the text is, which is a good reason to think twice before embedding large files.
Size: the 33% rule
Base64 represents every 3 bytes as 4 characters, so encoded data is about a third larger than the original:
| Original | Base64 (approx.) |
|---|---|
| 3 bytes | 4 characters |
| 30 KB icon | 40 KB |
| 1 MB image | 1.33 MB |
That’s fine for small icons and test data. For large images on websites, a normal file reference is better: it’s smaller, cacheable, and doesn’t bloat your HTML or CSS.
Standard vs URL-safe
| Variant | Characters 62 and 63 | Padding | Where it’s used |
|---|---|---|---|
| Standard | + and / | = | Email, data URLs, most APIs |
| URL-safe | - and _ | Usually none | JWTs, URL parameters, file names |
If an API rejects your Base64, check which variant it expects.
It is not encryption
Base64 hides nothing: anyone can decode it in a second. Credentials in an HTTP Basic auth header, for example, are only Base64-encoded, which is why such requests must use HTTPS. Use real encryption for secrets, and never treat Base64 as a way to obscure passwords.
Common uses
- Inspecting the payload of a JWT (use the JWT Decoder for a full view).
- Reading Basic auth headers while debugging.
- Embedding small images in HTML or CSS (the Image to Base64 tool adds ready-made snippets).
- Decoding attachments or payloads from logs and API responses.
Who encodes and decodes Base64
- Developers debug API payloads, data URLs and authorization headers.
- Email and web developers inspect encoded attachments and embedded images.
- Security learners see how encoding differs from encryption.
- DevOps engineers read Kubernetes secrets and configuration values, which are stored Base64-encoded.
A complete example: reading a Kubernetes secret value
A secret shows ZGF0YWJhc2UtdXNlcg== for a user name:
- Choose Decode and paste it.
- The result is database-user.
- Remember that Base64 hides nothing: anyone with the secret object can decode it, so access to secrets must be restricted.
Tips
- Turn on URL-safe for values that go into URLs or file names.
- Expect encoded data to be about a third larger.
Related tools
- Image to Base64 for images with HTML and CSS snippets.
- URL Encoder for percent-encoding text in URLs.
- Text to Binary to see the bytes themselves.
- Hash Generator for checksums, which can’t be reversed.
Checked against the current version of the Base64 Encode / Decode on .

