Loading...
Loading...
Drop in a JPG, PNG, WebP, GIF, or SVG to get a Base64 data URL with copy-paste snippets for CSS, HTML, and Markdown — or paste a Base64 string to decode it back to a downloadable image.
Base64 is a way of representing binary data — like an image — using only printable ASCII characters. The data URL form (a string starting with data:image/png;base64,...) lets you paste an entire image directly into HTML, CSS, JSON, Markdown, an email signature, or a server response, with no separate file required. Encoding is lossless: decoding the Base64 yields the exact same bytes that went in. The tradeoff is size — Base64 takes about 33% more characters than the underlying binary, so a 100 KB PNG becomes roughly 134 KB of Base64 text. That makes it ideal for tiny icons, inline SVGs, and one-off snippets, and a poor choice for big hero images. This tool encodes any image you drop in and decodes any Base64 string back to a downloadable image, with the work done entirely in your browser.
Use Image → Base64 to encode an image you have on disk. Use Base64 → Image to decode a string you've copied from a data URL, an API response, or a CSS file.
For encoding, drag a JPG, PNG, WebP, GIF, SVG, BMP, ICO, or AVIF onto the upload area or click to pick from your device. The image previews at the top of the result card.
Five paste-ready snippets are generated: the full data URL, the raw Base64 (no prefix), CSS background-image, HTML <img> tag, and Markdown image. Click Copy on the one you want.
Switch to Base64 → Image, paste either a full data URL or the raw Base64 portion. The tool auto-pads short strings and assumes PNG when the prefix is missing — click Decode to preview.
Once decoded, the preview card shows the image dimensions and an estimated file size. Click Download to save the original bytes back to disk with the correct extension.
1. The browser's FileReader.readAsDataURL() reads the image file as binary. 2. It groups the bytes into chunks of 3 (24 bits) and re-encodes each chunk as 4 ASCII characters. 3. The 64-character alphabet is A-Z, a-z, 0-9, plus '+' and '/' (with '=' for padding). 4. The output is prefixed with 'data:<mime>;base64,' to make it a usable data URL. 5. Decoding reverses every step: strip the prefix, normalize URL-safe variants, pad to a multiple of 4. 6. The decoded bytes are wrapped in a Blob and exposed via createObjectURL — or just used as the data URL directly.
The 33% size overhead is built into the math: 3 bytes of binary become 4 bytes of ASCII, a ratio of 4/3. That's a hard floor — there's no compressed Base64 variant in widespread use. The MIME prefix in a data URL isn't optional decoration: browsers, Markdown renderers, and email clients use it to decide how to render the bytes. If you paste raw Base64 with no 'data:image/...' prefix, this tool defaults to PNG, which is a safe guess for screenshots and icons but can produce a corrupted preview if the source was actually JPG. Best practice is to keep the full data URL format whenever you copy or paste.
Reference: MDN — Data URLs
| Use case | Best snippet to copy |
|---|---|
Inline a tiny icon directly in CSS | Copy the CSS background-image snippet. Eliminates an HTTP request for icons under ~5 KB. Works well for spinners, checkmarks, sprite-style icons. |
Embed an image in a JSON or REST API response | Copy the Data URL snippet. The receiver can drop it straight into <img src> or a CSS background. Common for chat apps, screenshots, and avatar uploads. |
Paste a screenshot into a Markdown blog post or GitHub issue | Copy the Markdown image snippet. Renders inline without uploading to a CDN. Some Markdown renderers (GitHub) reject very large data URLs — keep it small. |
Decode a Base64 string from an email or API into a usable file | Switch to Base64 → Image, paste the string, hit Decode, then Download. Works for raw Base64 too — defaults to PNG when the MIME is missing. |
Cut out the subject from any photo with on-device AI — no upload required.
Shrink JPG, PNG, or WebP files in your browser with an interactive quality slider.
Adjust, filter, rotate and crop photos in the browser — no uploads, no watermark.
Compose memes and screenshot collages with real layers — paste, drag, crop, caption, export.
Last updated