What Is Base64?
Base64 is a way to write any data, including images, files and text in any language, using only 64 safe characters: A to Z, a to z, 0 to 9, + and /, with = as padding at the end. It is defined in RFC 4648. Every 3 bytes become 4 characters, so Base64 is about 33% larger than the original.
You meet it everywhere: in email attachments, data URIs that put small images straight into HTML or CSS, API keys and basic auth headers, and JWT login tokens. This tool decodes all of these, encodes text and files, and runs entirely in your browser, so tokens and files never leave your device.
How to Use the Base64 Tool
- To decode, paste a Base64 string, a JWT token or a full
data:URI. The tool works out what it is and shows text, formatted JSON, an image preview or a file you can download. - To encode text, open Encode Text and type. Choose URL safe for links and tokens, and line breaks for email.
- To encode a file, open File to Base64 and pick an image, font or PDF. You get plain Base64, a data URI and, for images, a ready
<img>tag and CSS line. - Copy or download the result, or press Use Result as Input to go the other way.
Base64 Variants Explained
| Variant | Characters | Where it is used |
|---|---|---|
| Standard Base64 | A to Z a to z 0 to 9 + / and = | Email attachments, data URIs, most APIs |
| base64url | - and _ in place of + and /, padding often left out | JWT tokens, URLs, file names |
| MIME | Standard, with a line break every 76 characters | Email bodies and attachments |
| Data URI | data:image/png;base64, followed by the data | Small images and fonts inside HTML or CSS |
The decoder accepts all of these, adds missing padding, and handles text in Hindi, Marathi or any other script as UTF 8. The browser function btoa() on its own fails on such characters, which is a common cause of broken encoders.
Practical Tips
- Base64 is not encryption. Anyone can decode it in a second, so never use it to hide passwords or personal data.
- Read JWTs safely. The decoder shows who a token belongs to and when it expires, but it does not check the signature. Only your server can confirm a token is genuine.
- Inline only small images. A data URI saves a request, but it adds about a third to the size and cannot be cached on its own. Keep it for icons and logos under about 10 KB.
- Fix broken strings fast. If decoding fails, the tool shows the exact bad character or tells you the string was cut off when copied.
Work Smarter With Data and Images
See how image weight affects speed in how to optimize images without losing quality and WebP vs AVIF, and learn how tokens protect logins in building a PHP authentication system. Decoded a JSON payload? Tidy it up in the JSON formatter and validator.
Frequently Asked Questions
1How do I decode a Base64 string?
Paste it into the Decode box. The tool removes spaces and line breaks, accepts the URL safe version, adds missing padding and shows the result as text, formatted JSON, an image preview or a file to download.
2How do I decode a JWT token?
Paste the whole token, the three parts joined by dots. The tool decodes the header and payload, which are base64url, and shows each claim in a table with the issued and expiry times as readable dates. It does not verify the signature.
3How do I convert an image to Base64?
Open File to Base64 and choose the image. You get the plain Base64 text, a full data URI, an img tag and a CSS background line you can copy. The image never leaves your device.
4Is Base64 encoding secure?
No. Base64 only changes how data is written, it does not hide it. Anyone can decode it, so use real encryption or hashing for passwords and private data.