Report a problem

Base64 Decoder and Encoder

Paste Base64 and decode it to text, or to an image, PDF or any file with the type detected from its first bytes and images previewed on the spot. Switch to encode to turn text or an uploaded file into Base64, standard or URL-safe, wrapped for email or wrapped in a data URI. Free, no sign-up, nothing leaves your browser.

Your data never leaves your browser

Decoding accepts standard and URL-safe Base64, ignores whitespace, fixes missing padding and strips a data: URI prefix. Drop a file onto the box to encode it.

Decoded image preview
Input-
Decoded size-
Detected type-
Variant-

Text is shown as UTF-8. Binary results show their detected type and can be downloaded with the right extension.

How Base64 works

Base64 takes every 3 bytes of input, 24 bits, and splits them into four 6-bit groups. Each group indexes one of 64 characters: A to Z, a to z, 0 to 9, + and /. When the input is not a multiple of 3 bytes, the last block is padded with one or two = signs. The result is text that survives any channel built for text: email, JSON, XML, URLs and HTML attributes, at the cost of being a third longer than the original.

Decoding reverses the mapping. A decoder needs the string to be a multiple of 4 characters once whitespace is removed, and it needs every character to be in the alphabet. This one is forgiving about the things that break strict decoders: it strips line breaks and spaces, tolerates missing padding, recognises the URL-safe alphabet, and pulls the payload out of a data: URI.

Standard, URL-safe, MIME and data URI

VariantAlphabet endingPaddingLine breaksUsed by
Standard (RFC 4648 section 4)+ /=NoneHTTP Basic auth, most APIs, btoa() in browsers
URL-safe, Base64URL (section 5)- _Usually omittedNoneJSON Web Tokens, OAuth, file names, query strings
MIME (RFC 2045)+ /=Every 76 charactersEmail attachments, PEM certificates use 64
Data URI+ /=NoneInline images and fonts in HTML and CSS: data:image/png;base64,...

The encode options above produce each of these. URL-safe swaps the two symbols and drops padding, wrap inserts a newline every 76 characters, and the data URI option prefixes the output with the MIME type of the text or uploaded file so it can be pasted straight into an src attribute or a CSS url().

Base64 to image, PDF or any file

A great deal of Base64 in the wild is not text at all. Images embedded in HTML emails, PDF attachments in API responses, ZIP files in configuration blobs and fonts in stylesheets all arrive as Base64. Decoding them to a text box produces gibberish, which is why this decoder inspects the first bytes of the result for file signatures. PNG, JPEG, GIF, WebP, BMP and SVG are shown as an image preview; PDF, ZIP (which also covers DOCX, XLSX and PPTX), GZIP, MP3, MP4, WAV and OGG are identified by name. Whatever the type, the download button saves the bytes with the right extension, so Base64 to PDF or Base64 to PNG is one paste and one click.

Going the other way, upload or drop a file in encode mode to get its Base64. Turn on the data URI option to embed a small image directly in a page. Keep such inline assets small: a data URI cannot be cached separately from the page, and Base64 makes the file a third larger.

Why Base64 decoding fails

Frequently asked questions

Is Base64 encryption?

No. Base64 is an encoding, not encryption: it turns bytes into a safe set of 64 text characters that anyone can turn back with a decoder like this one. It hides nothing. Use it to move binary data through text-only channels, never to protect a password or a secret.

Why does my decoded Base64 look like garbage?

Because the original data was not text. Base64 often wraps images, PDFs, ZIP files or compressed data, and the decoded bytes only make sense in the right program. This decoder checks the first bytes for known file signatures, previews images, and offers the result as a download with the correct extension. If it reports plain text but the letters are wrong, the source was probably encoded in a charset other than UTF-8.

What is the difference between Base64 and Base64URL?

Standard Base64 uses + and / as its last two characters and pads with =. Base64URL (RFC 4648 section 5) swaps them for - and _ and usually drops the padding, so the string is safe inside URLs, file names and JSON Web Tokens without escaping. The decoder accepts both automatically and tells you which one it found.

Why is Base64 output about 33% larger than the input?

Every 3 bytes of input become 4 characters of output, because each Base64 character carries only 6 bits. That is a 4 to 3 ratio, a third larger, plus up to two padding characters at the end and, for MIME-style output, a newline every 76 characters.

Is anything I paste or upload sent to a server?

No. Encoding, decoding, file reading and image previews all happen in your browser with JavaScript. Nothing you paste or upload leaves your device, and the page keeps working offline once it has loaded.

Related tools