How to use the Base64 tool
In Text ⇄ Base64 mode both boxes are live. Type in the left box and the Base64 appears on the right; paste Base64 on the right and the decoded text appears on the left. The status line tells you how many bytes were encoded, the size overhead, and anything it had to tidy up — whitespace, line breaks, a missing =, a data: prefix or URL-safe characters are all handled automatically. Tick Hex view to see the underlying bytes.
File → Base64 reads any file on your device — PNG, JPEG, SVG, PDF, a web font, a ZIP — and gives you raw Base64, a complete data URI, an HTML <img> tag or a CSS background-image rule, with a preview and the before-and-after sizes. Base64 → File does the reverse: paste Base64 or a data URI, and the tool identifies the file from its first bytes, previews images, audio, video and text, and downloads it with the right extension.
If a decode produces binary rather than text, the tool says what it looks like — “PNG image, 14.2 KB” — instead of filling the box with garbage, and offers to open it in Base64 → File.
What Base64 is (and isn’t)
Base64 represents binary data using 64 safe printable characters: A–Z, a–z, 0–9, + and /, with = as padding. Every 3 bytes become 4 characters, so the output is about 33% larger than the input (plus line breaks if wrapped). It exists so binary data can travel through systems built for text: email attachments (MIME), JSON and XML payloads, HTTP Basic authentication headers, data URIs in HTML and CSS, and PEM certificates.
It is not encryption. Anyone can decode it instantly, so never treat a Base64 string as hidden — an Authorization: Basic header, for example, is just the username and password in Base64. If you are creating a secret, use the password generator; if you want to see text as raw bits instead, try text to binary.
| Variant | Characters 62/63 | Padding | Used in |
|---|---|---|---|
| Standard (RFC 4648 §4) | + / | = | MIME email, data URIs, most APIs |
| URL-safe (RFC 4648 §5) | - _ | usually omitted | JWTs, URLs, filenames, WebAuthn |
| MIME | + / | = | Email bodies, lines of 76 characters |
Text encodings, emoji and why ‘btoa’ fails
Base64 encodes bytes, not characters, so text has to be turned into bytes first. Almost everything today uses UTF-8, where “é” is two bytes and an emoji four, and that is the default here — so £, accents, Arabic, Chinese and emoji all round-trip correctly. The browser’s built-in btoa() only accepts Latin-1 and throws “The string to be encoded contains characters outside of the Latin1 range” on anything else; this tool does not have that limit.
Choose ISO-8859-1 when you are matching a legacy system that encodes one byte per character, or UTF-16LE for Windows APIs and PowerShell’s -EncodedCommand. If decoded text looks like é instead of é, the data was UTF-8 but decoded as Latin-1 — switch the encoding. Line breaks are encoded exactly as they are in the box; browsers normalise typed line breaks to LF, so if a system expects CRLF, encode the file instead.
Fixing Base64 that won’t decode
- Invalid character. The error names the character and its position. A
%means the string is URL-encoded (%2Bis +); dots usually mean a JWT, which has three separately encoded parts; curly quotes mean a word processor got involved. - Impossible length. Valid Base64 is never one character longer than a multiple of four. The string has been truncated or had a character added — common when copying from a terminal or a log that wraps lines.
- Padding in the middle. Two Base64 strings have been joined. Decode each part separately.
- Mixed alphabets. Both
+/and-_appear, so something has edited the string. - Decodes to an unexpected type. The type is detected from the file’s magic bytes, not from any label, so a “PNG” that is really a WebP will be identified correctly — and you are told when a data URI’s declared type disagrees with its content.
For images over about 10 KB, a normal file is usually better than an inline data URI: it is cached separately and doesn’t bloat every page. Decoding a JSON payload? Paste the result into the JSON formatter to read it.
Frequently asked questions
Is Base64 a form of encryption?
No. Base64 is a reversible encoding with no key, so anyone can decode it in a second, including with this page. It is designed to move binary data through text-only channels, not to hide it. Use proper encryption, or at least a strong password, when something needs to stay secret.
Why is the Base64 output bigger than my file?
Base64 turns every 3 bytes into 4 characters, so the output is about 33% larger, plus a little more if it is wrapped into 76-character lines. That overhead is why large images are normally better served as separate files than embedded as data URIs.
How do I convert an image to Base64 for HTML or CSS?
Choose File → Base64, pick or drop the image and select the HTML image tag or CSS output. The tool produces a complete data URI with the correct MIME type, ready to paste. It works with PNG, JPEG, GIF, WebP, AVIF and SVG. The image is read on your device and never uploaded.
What is URL-safe Base64?
It is the variant defined in RFC 4648 section 5, which replaces + with - and / with _ so the result can go in URLs and filenames without escaping, and usually drops the = padding. JSON Web Tokens use it. The decoder recognises either alphabet automatically.
Why does decoded text show strange characters like é?
The bytes were encoded as UTF-8 but decoded using a different character set, or the other way round. Switch the text encoding option to match the system that produced the data. If the result is binary, such as an image or PDF, the tool detects that and offers to download it instead.
Can I decode a Base64 string back into a PDF or image file?
Yes. Use Base64 → File and paste the string, with or without a data: prefix. The tool reads the file’s signature bytes to identify it — PDF, PNG, JPEG, ZIP, MP3 and many more — previews it where possible, and downloads it with the right extension and a name you can change.