Convert an image to Base64, or turn Base64 back into an image
LOCALSometimes an image cannot be a separate file: an HTML email has to carry its own logo, a JSON request needs the picture as a string, or a CSS file must work without a second download. This tool reads the original bytes in your browser and writes them as a Base64 string, wrapped in a data URI or already placed inside an HTML tag, a CSS rule, Markdown or a JSON object. The reverse tab accepts a pasted Base64 string or data URI and rebuilds a downloadable image, which is useful when you are debugging an API response or a stylesheet. Everything runs locally, the original file is untouched and the encoder shows exactly how much larger the text version is.
How it works
- 01
Drop the image
Choose a PNG, JPG, GIF, WebP, SVG or BMP file, or drag it onto the box. The tool reads the raw bytes with the File API instead of redrawing the image on a canvas, so the Base64 string represents the exact file you selected, including an SVG's text markup or a GIF's animation frames. File size, MIME type and pixel dimensions appear next to the preview.
- 02
Pick the output form
Data URI gives the complete data:image/...;base64,... string. Raw Base64 drops the prefix when the receiving system already knows the type. HTML wraps the URI in an img tag, CSS produces a background-image rule, Markdown gives an image link and JSON returns an object with name, MIME type and the encoded data. All six come from the same bytes, so switching never re-encodes anything.
- 03
Copy or download
Copy puts the current output on the clipboard; the download button saves it as a .txt file, which is convenient for build scripts or for keeping a record. The line counter shows the encoded length and the percentage increase over the original, and a warning appears once the string passes one megabyte, because at that point inlining usually costs more than it saves.
- 04
Decode when you need the image back
Switch to the decode tab, paste a data URI or a bare Base64 string and press decode. Whitespace and line breaks are ignored, the MIME type is read from the data URI or detected from the file signature, and the result is shown with a download link. If the string contains something other than an image, the tool says so instead of producing a broken file.
When to use it
HTML email with a visible logo
Many email clients block remote images until the reader allows them, so a logo hosted on a website may never appear. Embedding a small logo as a data URI keeps it visible in the first render. Keep it tiny, because some clients still limit the total message size and data URIs cannot be cached separately.
JSON APIs and webhooks
Some upload endpoints, AI services and webhook payloads expect the image inside the JSON body as a Base64 string rather than as a multipart file. The raw Base64 output can be pasted straight into the request field. Check the service documentation for a size limit first, since Base64 adds about a third to the payload.
Tiny icons in CSS
A small icon used on every page can be inlined as a CSS background so the browser does not make another request. The tool shows the encoded length before you commit, which makes the break-even decision concrete: a two-kilobyte icon is usually worth inlining, a two-hundred-kilobyte hero image is not.
Single-file demos and offline pages
A prototype, a code sample or a documentation page that must work from a single HTML file cannot depend on external assets. Encoding the images into the file makes it self-contained. The decode tab is the counterpart: when you find a long data URI in someone else's file, paste it here to see what image it contains.
Questions
Is the image uploaded anywhere?
No. The file is read with the browser's File API, encoded to Base64 in memory and never sent to a server. There is no upload endpoint and no stored copy. Once the page has loaded, you can switch off the network and both encoding and decoding still work, which is the easiest way to confirm the claim.
How much larger is Base64 than the original file?
About thirty-three percent, because every three bytes become four text characters. A 30 KB image turns into roughly 40 KB of text, and the data URI prefix adds a few dozen more characters. The tool shows the exact numbers for your file, so you can judge whether inlining is worth it instead of guessing from a rule of thumb.
Does Base64 compress or encrypt the image?
Neither. Base64 is only a way of writing binary bytes with printable characters; it hides nothing and compresses nothing, in fact it makes the data larger. Anyone who has the string can decode it in seconds. If the goal is privacy, use encryption, not encoding, and never treat a data URI as a secret.
When should I embed an image instead of linking it?
Inline small, stable assets: icons, spinners, logos and simple backgrounds under a few kilobytes that appear in a stylesheet or an email. Link everything else. A large data URI cannot be cached on its own, is re-downloaded with the document every time, and delays the first paint because the browser must parse the string before it can decode the image.
Why does my inline image not show up on a website?
The most common cause is a Content-Security-Policy that allows images only from certain hosts and does not include data:. The markup is correct but the browser blocks it silently. The second cause is a data URI that was truncated when copied; a missing character near the end is enough to break decoding. Check the console and the full string length.
Can I use the raw Base64 output directly in HTML?
Not in an img src. The src attribute needs the full data URI with its MIME prefix, otherwise the browser does not know what the bytes represent. Raw Base64 is meant for systems that carry the type separately, such as a JSON field paired with a mime key, or a database column with a known format.
What happens when I decode a string without a data: prefix?
The tool reads the bytes first and detects the format from the file signature: PNG, JPEG, GIF, WebP, BMP and SVG are recognised. That makes bare Base64 usable for images pulled out of a database or an API response. If the bytes are not an image at all, decoding is refused with a message rather than producing a file that cannot be opened.
Does embedding a Base64 image help page speed?
Only for very small images. Inlining removes one HTTP request, which can help a critical icon during the first paint. Above a few kilobytes the extra bytes in the HTML or CSS delay the whole document, and the browser cannot cache the image separately for repeat visits. Modern HTTP/2 and HTTP/3 servers already handle many small requests efficiently, so measure before inlining a large asset.
Is there a size limit in the tool?
There is no server-side limit because nothing is uploaded. The practical ceiling is your device's memory and the point where a text area becomes awkward to handle. Encoding a few megabytes of image data works, but pasting such a string into a code editor or a database field is slow. Prefer a normal image file at that size.
Does it change the image itself?
No. The bytes of the file are copied as they are, so colour, compression artefacts and transparency are identical to the original. Decoding that string returns the same bytes. The only thing that changes is the representation: binary becomes text, and the text is larger than the binary was.