Base64 Encode and Decode converts text to Base64 and back, decodes Base64 strings and data URLs into images or files, and turns any file up to 20 MB into Base64 or a data URL for HTML and CSS. Text is handled as UTF-8, so every language and emoji works. Everything happens in your browser.
How to use it
- Choose a mode: Encode text, Decode or File or image to Base64.
- Encode text: type or paste text. Tick URL-safe for URLs and tokens, or Wrap lines at 76 characters (MIME) for email.
- Decode: paste Base64 or a full
data:URL. Text appears as text; images are previewed; other files can be downloaded. - File or image: choose a file. Leave As a data URL ticked to get a string ready for
srcorurl(), or untick it for plain Base64. - Click Copy or Download. Use result as input feeds the result back in, for example to decode what you just encoded.
The three modes
| Mode | Input | Output |
|---|---|---|
| Encode text | Any text | Base64, standard or URL-safe |
| Decode | Base64 or a data: URL | Text, an image preview or a file |
| File or image to Base64 | A file up to 20 MB | Base64 or a data URL |
Decoding files
When you decode, the tool looks at the first bytes of the result to see what it is. It recognises PNG, JPEG, GIF and WebP images, PDF documents, ZIP archives, gzip data and WOFF, WOFF2 and TTF fonts. Images are shown as a preview and every recognised file can be downloaded with the right extension. If the data is text, it is shown as UTF-8 text. That makes it quick to check what an unknown Base64 string in a log, an email source or an API response really contains.
Images in HTML and CSS
A data URL puts a small image straight into your code, so the browser needs no extra request:
<img src="data:image/png;base64,iVBORw0KGgo..." alt="Logo">
.icon { background-image: url("data:image/svg+xml;base64,PHN2Zy..."); }
This suits small icons, logos in email templates and single-file demos. For large photos it is a poor trade: Base64 is about a third bigger, and the image can no longer be cached on its own. Shrink images first with Compress Image or Resize Image.
Standard, URL-safe and MIME
- Standard Base64 uses
+,/and=padding. It is what most APIs and libraries expect. - URL-safe Base64 swaps
+and/for-and_and drops the padding, so the text works in URLs, cookies and file names. JSON Web Tokens use this form. - MIME line wrapping breaks the output every 76 characters, as email attachments do.
Tips
- Reading a JSON Web Token: the middle part between the two dots is URL-safe Base64. Paste it into Decode to read the claims, then view them neatly in the JSON Formatter.
- Spaces and line breaks in pasted Base64 are fine; they are ignored when decoding.
- Base64 is not a secret. Never treat encoded text as protected. For real secrets, start with a strong password from the Password Generator.
Private by design
Text and files are encoded and decoded on your own device and never uploaded. See how it works.