Base64 Encoder / Decoder
Encode or decode Base64 locally in your browser. Text, files, UTF-8, Base64URL and Data URLs are supported; your content is not sent to the server.
How it works
Encoding uses the browser's UTF-8 and binary primitives, then Base64 conversion. Decoding validates malformed input, accepts line-wrapped Base64, and preserves binary bytes for download. Base64 is encoding, not encryption.
What this tool does
Encode or decode Base64 text, files, Base64URL values, and data URLs.
What Base64 is (and isn't)
Base64 turns any bytes, text, images or files, into a string of 64 safe characters: A–Z, a–z, 0–9, + and /, with = as padding. It exists so binary data can travel through systems built for text: email, JSON, URLs, HTML, HTTP headers.
It is not encryption. Anyone can decode Base64 instantly; there's no key. If you see a password or API key "protected" with Base64, it isn't protected.
How much bigger Base64 makes your data
Every 3 bytes become 4 characters, so encoded data is about 33% larger:
| Original | Base64 |
|---|---|
| 3 bytes | 4 characters |
| 100 bytes | 136 characters |
| 1,000 bytes | 1,336 characters |
| 1 MB (1,048,576 bytes) | about 1.33 MB (1,398,104 characters) |
That's why embedding large images as Base64 data URLs slows pages down: they're a third bigger than the file and can't be cached separately.
Padding: the = at the end
Base64 works in groups of 3 bytes. When the input doesn't divide evenly, = fills the gap:
| Input | Bytes | Base64 |
|---|---|---|
a |
1 | YQ== |
ab |
2 | YWI= |
abc |
3 | YWJj |
abcd |
4 | YWJjZA== |
Some systems (JWTs, many URL-based tokens) drop the padding. The decoder accepts Base64 with or without it.
Base64 vs Base64URL
Standard Base64 uses + and /, which have special meanings in URLs and file names. Base64URL swaps them for - and _:
| Bytes | Base64 | Base64URL |
|---|---|---|
FB FF BF |
+/+/ |
-_-_ |
Use Base64URL for anything that goes in a URL, a filename or a JWT. Use standard Base64 for email attachments, data URLs and most APIs. If a decoder rejects your string with "invalid characters", check whether it contains - or _ (it's Base64URL) or + and / (it's standard).
The accented-text bug in JavaScript
The browser's built-in btoa() only understands Latin-1 characters, and handles anything else badly:
| Input | btoa() |
Correct UTF-8 Base64 |
|---|---|---|
hello |
aGVsbG8= |
aGVsbG8= |
São Paulo |
U+NvIFBhdWxv (wrong, silently) |
U8OjbyBQYXVsbw== |
😀 |
throws InvalidCharacterError |
8J+YgA== |
So btoa("São Paulo") doesn't fail; it returns a string that other systems decode as garbage. This tool always encodes text as UTF-8, which is what every other language and API expects. In your own code, encode with TextEncoder first, or in Node.js use Buffer.from(text).toString("base64").
Data URLs
A data URL puts a whole file inside a string:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...
You can paste a full data URL into the decoder; it recognizes the prefix and gives you the file back to download with the right type. Data URLs are handy for small icons in CSS or email templates. For anything larger than a few kilobytes, a normal file is faster.
FAQ
Is my data sent to a server?
No. Encoding and decoding happen in your browser, including files. Nothing is uploaded to Docspira.
Can I encode a file, like an image or a PDF?
Yes. Choose a file and the tool gives you its Base64 text, or decode Base64 back into a downloadable file. The bytes are preserved exactly.
Why does my decoded text look like random symbols?
Either the Base64 represents binary data (an image, a zip file, compressed or encrypted data), not text, or the text was encoded with a different character set. Try downloading the decoded result as a file instead of reading it as text.
What does "invalid padding" mean?
The number of = characters at the end doesn't match the length of the data. That usually means the string was cut off when it was copied.
Can Base64 contain line breaks?
Email (MIME) wraps Base64 at 76 characters per line. The decoder accepts line-wrapped input and ignores the breaks.
Before you start
Base64 is an encoding for transport, not encryption; decoding it does not make sensitive content safe to share.
Privacy
This tool runs in your browser; the text or file you choose is not uploaded for processing. Read the privacy details.