Base64 encoder and decoder
Encode or decode Base64 text and files, build data URIs, and switch to the URL-safe alphabet. Full UTF-8 support, everything stays on your device.
- Runs in your browser
- Nothing you enter is sent
- Free, no account
0 characters
How to encode and decode Base64
- Text tab — paste text and choose Encode, or paste Base64 and choose Decode. The result appears immediately in the second pane.
- File → Base64 — drop any file to get its Base64 representation, or flip the switch to get a complete
data:URI with the correct MIME type already attached. - Base64 → File — paste raw Base64 or a data URI, confirm the detected file type, and download the reconstructed file.
- Use the URL-safe switch when the value has to travel inside a URL, and the wrap switch when a protocol requires 76-character lines.
What Base64 actually does
Base64 takes three bytes (24 bits) and rewrites them as four characters drawn from a 64-symbol alphabet,
each carrying 6 bits. That is why the output is always about 133% the size of the input, and why the
length is always a multiple of four once padding is applied. When the input length is not divisible by
three, one or two = characters are appended so the decoder knows how many bytes to discard.
| Input bytes | Base64 characters | Padding |
|---|---|---|
3 (e.g. abc) | 4 — YWJj | none |
2 (e.g. ab) | 4 — YWI= | one = |
1 (e.g. a) | 4 — YQ== | two = |
Why other tools break on accents and emoji
The browser function btoa() only accepts characters with a code point below 256, because it
was designed for binary strings, not Unicode text. Feed it café and it throws; feed it a
naively converted string and you get mojibake back. This tool converts your text to UTF-8 bytes with
TextEncoder before encoding, and decodes with a strict UTF-8 decoder afterwards, so
café, 日本語 and 👋 all round-trip byte for byte.
Standard versus URL-safe alphabet
| Position 62 | Position 63 | Padding | Where it is used |
|---|---|---|---|
+ | / | = | MIME, email, most APIs (RFC 4648 §4) |
- | _ | usually omitted | JWTs, URLs, file names (RFC 4648 §5) |
The decoder here accepts either alphabet, with or without padding, and ignores line breaks, so you can paste a value straight out of a log line or a config file without cleaning it up first.
Data URIs for CSS and HTML
A data URI embeds a file directly in a document: data:image/svg+xml;base64,PHN2Zy…. It
removes a network request, which is worth doing for tiny assets — an inline SVG icon, a 1-pixel spacer,
a font subset used above the fold. It is a poor trade for anything large, because the base64 payload
cannot be cached separately, cannot be compressed as efficiently as the raw binary, and blocks the
stylesheet or HTML it lives in from finishing.
A rough rule: inline below about 2 KB, link above it, and always measure.
Base64 is not encryption
This comes up constantly in security reviews. Base64 is a transport encoding with a published, reversible alphabet — anyone can decode it instantly, including on this page. A password, an API key or a session token stored as Base64 is stored in plain text with an extra step. If you need confidentiality, encrypt, then Base64-encode the ciphertext if the transport requires text.
Everything stays on your device
Files are read with the browser File API and processed in chunks so multi-megabyte inputs
do not freeze the tab. Nothing is uploaded, so encoding an internal certificate, a signed document or a
private key is as safe here as running base64 in your own terminal.
Questions
Why do accented or emoji characters break in other Base64 tools?
Because they call btoa() directly, which only accepts code points below 256. This tool encodes text to UTF-8 bytes first, so "café", "日本語" and emoji round-trip exactly.
What is the difference between standard and URL-safe Base64?
URL-safe Base64 (RFC 4648 §5) replaces + with - and / with _ and usually drops the = padding, so the result can sit in a URL path or query string untouched. JWTs use this variant.
How do I turn an image into a data URI for CSS?
Switch to File mode, drop the image in, and copy the data URI output. It already carries the correct MIME type prefix, so you can paste it straight into a CSS url() or an img src attribute.
Does Base64 encrypt anything?
No. Base64 is an encoding, not encryption — anyone can decode it in a second. Use it for transporting binary data safely through text channels, never to protect a secret.
Is there a file size limit?
Only your available memory. Base64 output is about 33% larger than the input, so a 100 MB file becomes roughly 133 MB of text, which most browsers handle but will feel sluggish to render.