MiServe DevTools

Your lid

Pin tools here. They are saved in this browser.

Base64 Encoder / Decoder

Encode text or a file to Base64 and decode it back, with the URL-safe alphabet, optional padding and MIME line wrapping.

Runs in your browser. Nothing you paste is uploaded.

About this tool

What Base64 is

Base64 writes arbitrary bytes using 64 printable ASCII characters: A–Z, a–z, 0–9, + and /. Every three bytes become four characters, and = pads the last group when the input length is not a multiple of three. It is defined in RFC 4648.

It exists so that binary data can travel through channels built for text: email attachments, data: URIs in HTML and CSS, binary fields in JSON, the HTTP Authorization: Basic header and the three parts of a signed JWT.

Base64 is an encoding, not encryption. Anyone can decode it, so it hides nothing.

The variants you will meet

The URL-safe alphabet replaces + and / with - and _, so the value can sit in a URL or a file name without escaping. JWTs use it and also drop the padding.

MIME (RFC 2045) breaks the output into lines of at most 76 characters. A data URI puts a media type in front of the payload, as in data:image/png;base64,…, and uses the standard alphabet, not the URL-safe one.

When decoding, this tool accepts both alphabets, missing padding, spaces, tabs and line breaks, and skips a data:…;base64, prefix. If a character does not belong, it names the character and its position.

Text, bytes and files

Base64 encodes bytes, so text has to become bytes first. This tool uses UTF-8, the encoding most systems expect today. JavaScript's own btoa() only accepts characters up to U+00FF and throws on anything else, which is why code that passes an emoji straight to btoa() fails. A letter such as é does not throw, but btoa() encodes it as one Latin-1 byte and not as the two bytes UTF-8 uses.

After decoding, the tool checks whether the bytes are valid UTF-8 text without control characters. If they are not, it says so, recognises PNG, JPEG, GIF, WebP, PDF and ZIP data by their first bytes, and lets you download the bytes as a file. Files you choose are read by the browser and never leave your device.

Questions

Is Base64 a form of encryption?

No. Base64 is a reversible encoding with no key, so anyone can decode it. Do not use it to protect passwords, tokens or personal data.

Why is the Base64 output larger than the input?

Each Base64 character carries six bits instead of eight, so every three bytes need four characters. The result is about one third larger than the original, plus padding and any line breaks.

What is the difference between Base64 and base64url?

base64url is the variant in section 5 of RFC 4648. It uses - and _ in place of + and /, and often leaves out the = padding, so the value is safe in URLs and file names. The data is the same and only those characters differ. This tool decodes both.

Is the file I encode uploaded anywhere?

No. The file is read by your browser and encoded on your device. It is not sent to a server.

More in Encoding