Base64 Encoder & Decoder
Convert text to and from Base64 right in your browser — Unicode-safe, with URL-safe variants, padding and line-wrap control, plus file ↔ Base64 (data URI) conversion.
Type or paste text and the conversion runs live as you type. Encode with the standard or URL-safe
alphabet, keep or strip = padding, and wrap long output for MIME emails. Decoding accepts
both alphabets, padded or unpadded, and reports invalid characters with their exact position — and
when the bytes are not text, you get a hex dump instead of mojibake. The File tab turns any file into
Base64 or a full data: URI, and turns pasted Base64 back into a downloadable file with an
image preview.
Text → Base64
Base64 → Text / Bytes
File → Base64
Click or drop a file below. You get the raw Base64 and the full data: URI (always standard Base64 with padding, as data URIs require).
Drop a file here or click to browse
Any file type — images, documents, code, anything. It never leaves your browser.
Base64 → File
Paste Base64 (or a full data: URI — the prefix is detected automatically) and download the original file. Images get a live preview.
What is Base64?
Base64 is a family of binary-to-text encodings. It works by grouping the input into 24-bit chunks
(three bytes) and splitting each chunk into four 6-bit values; each value picks one character from a
64-character alphabet — hence “Base64”. Because four characters are emitted for every
three input bytes, the output is always about 33% larger than the input (plus up to two =
padding characters).
Why does it exist?
The early internet only carried 7-bit ASCII, so any binary data — a photo, a font, a compiled program — had to be smuggled through text-only channels. Base64 does exactly that. You will meet it:
- MIME email attachments (RFC 2045) — every binary attachment in an email is Base64 inside the
.eml. - Data URIs —
data:image/png;base64,iVBORw0KGgo…embeds a file directly in HTML or CSS. - JWTs — the header and payload of a JSON Web Token are URL-safe Base64.
- HTTP Basic auth —
Authorization: Basic dXNlcjpwYXNzisbase64("user:pass"). - API payloads and config files — certificates, keys and avatars pasted as strings.
Standard vs URL-safe
| Alphabet | Characters | Used when |
|---|---|---|
| Standard (RFC 4648) | A–Z a–z 0–9 + / | Email, data URIs, most APIs |
| URL-safe (RFC 4648 §5) | A–Z a–z 0–9 - _ | URLs, JWTs, file names — + and / are reserved characters in URLs |
The two alphabets differ in exactly two characters (+// vs -/_).
This tool decodes both interchangeably; the output option above picks which one to emit.
Padding
The final 24-bit group may contain only one or two bytes. Standard Base64 pads the output with =
so its length is always a multiple of four:
"Hi"(2 bytes) →SGk="How"(3 bytes) →SG93— no padding needed
Many URL schemes and APIs strip the padding. This tool can emit unpadded output, and its decoder accepts padded or unpadded input — it only complains when the padding contradicts the data length.
The UTF-8 gotcha
Base64 encodes bytes, not characters. If your text contains non-ASCII characters, the result
depends on the character set: “café” is 5 bytes in UTF-8 (the é is C3 A9) but 4 bytes
in Latin-1. Decode those UTF-8 bytes as Latin-1 and you get the classic mojibake “café”.
This tool always treats text as UTF-8 — the same assumption browsers, JSON and modern APIs make.
Common pitfalls
- Line wrapping. MIME wraps Base64 at 76 characters. Pasting wrapped output into a decoder that does not ignore newlines produces “invalid character” errors. This decoder ignores whitespace, and the encoder can wrap output for email.
- Double encoding. Encoding an already-encoded string (or a string that already contains a data URI) produces a valid but useless result. If the output looks twice as long as it should, check you did not encode the encoding.
- Binary vs text. The Base64 of an image is not a text file — round-tripping it through a text editor can insert a BOM or change line endings and corrupt it. Use the File tab for files.
- Trailing garbage. A stray character after the padding — a quote copied from JSON, a counted newline — is the most common decode failure. The error message points at the exact position.
Want to do this from the command line instead? See the PowerShell Base64 encoding / decoding tech tip.
Nothing on this page leaves your browser: there is no server round-trip when you type, paste or drop a file, no analytics on your inputs, and no storage of any kind.