01 / Formats
Six ways to paste
Data URL, plain Base64, CSS, HTML, Markdown or JSON, switched in one menu.
Free tool
Drop one or more pictures to turn each into Base64: a data URL, plain Base64, a CSS background line, an HTML img tag with the width and height, a Markdown image or a JSON field. You see each file's size before and after, since Base64 is about a third bigger, and copy one or all of them with one click. Too long? Make the picture smaller first, or write an SVG as plain text. PNG, JPG, WebP, GIF, SVG and ICO all work, with no size limit. Nothing is uploaded.
Need a custom tool, app or website? Contact us →Make it smaller first
Inline small icons and logos; link big photos as files, because Base64 cannot be cached on its own and makes pages heavier. Settings are kept in this browser.
Converted in your browser. Your pictures are never uploaded.
Pictures as text
01 / Formats
Data URL, plain Base64, CSS, HTML, Markdown or JSON, switched in one menu.
02 / Size
Base64 text is about 33% bigger than the file. The sizes are shown side by side.
03 / Many
Drop a batch of icons and copy each one.
Guide
An image to Base64 converter turns a picture file into a long line of plain text, so you can paste the picture straight into HTML, CSS, Markdown or JSON instead of linking to a separate file. By default this tool reads your file exactly as it is, with no resizing or recompressing, and writes it out in the format you pick. If the text is too long, it can shrink the picture first. It shows the size of the file and the size of the text side by side, so you can see what embedding will cost.
| Give me | Looks like | Paste it into |
|---|---|---|
| Data URL | data:image/png;base64,iVBORw0... | Anywhere a picture address goes: an src, a url(), a JavaScript string |
| Plain Base64 | iVBORw0KGgo... | JSON for an API, a database field, or code that adds its own prefix |
| CSS background | background-image: url("data:..."); | A rule in your stylesheet |
| HTML img tag | <img src="data:..." width="64" height="64" alt="logo"> | An HTML page or an email template |
| Markdown image | Markdown's image syntax, with the file name as alt text and the data URL in brackets | A README or notes app that shows Markdown |
| JSON field | {"name":"logo.png","type":"image/png","width":64,...} | An API request, a test fixture or a config file |
The HTML tag already has the picture's real width and height, which stops the page from jumping as it loads. The alt text is the file name without its extension. Change it to a short description of the picture before you publish.
Base64 writes every 3 bytes of the file as 4 text characters, so the text is about a third bigger. A data URL also adds a short label at the start. Here are two examples:
data:image/png;base64, adds 22 more, so 8,022 characters, about 8 KB.The icon is a fair trade: one less file to fetch for 2 KB of extra text. The photo is not, because those 400 KB load every time the page or stylesheet loads, and the browser cannot keep the picture in its cache on its own. When a picture is over 100 KB, the tool warns you.
Shrink a picture before converting and the text shrinks with it. Under Make it smaller first, set a Width, such as up to 128 px for an icon, and a File type. WebP is usually the smallest, JPG suits photos with no see-through parts, and PNG keeps every pixel exact. JPG and WebP also get a Quality setting. Each picture shows its new size in brackets, and if saving again would make a file bigger, the original is kept. A moving GIF keeps only its first frame when it is saved again, so leave the settings at As it is for those. For more control, use the image compressor first.
An SVG is already text, so it works as Base64 too. The data URL starts with data:image/svg+xml;base64,. Because the SVG is text, it can also go in a data URL without Base64: tick Write SVG as text, not Base64 and the tool writes data:image/svg+xml, followed by the SVG with only the characters that must be escaped changed, such as < to %3C. That is usually shorter than Base64 and still works in CSS and in an src. Plain Base64 is not possible in that mode, so you get the data URL. If the SVG is a simple icon, check it is not drawn with a font or linked pictures that will not travel with it.
You can also do it in Terminal, which is built in. Type base64 -i icon.png | pbcopy and press Return. The plain Base64 for icon.png is now on your clipboard. You still need to add the data:image/png;base64, label yourself for a data URL.
To go the other way, paste Base64 into the Base64 decoder to get the picture back. Making icons for a site? The favicon generator builds every size you need.
Questions
Drop the picture and copy the result. Pick the format you need under Give me.
The whole file written as text after data:image/png;base64, so it can sit inside HTML or CSS.
Base64 uses 4 characters for every 3 bytes, about a third more.
Use the Base64 decoder.
No. They are read and converted in this browser tab, so there is no file size limit apart from your computer's memory.
Use Make it smaller first: a smaller width and WebP usually cut the text the most. For an SVG, tick Write SVG as text, not Base64.
Yes. Drop them all, then use Copy all, or Save all as JSON for one file with every picture by name.
Pick HTML img tag under Give me and copy it. The whole picture is inside the src, so you can paste the tag into any page without uploading a file.
No. Base64 is a different way to write the same bytes, so the picture is identical. It only makes the data larger.
No. Anyone can turn Base64 back into the picture in seconds. It is a way to store a file as text, not a lock.
A data URL is the Base64 with a label in front, such as data:image/png;base64,, that tells the browser what kind of file it is. Plain Base64 is just the encoded text, for code that adds the label itself or does not need one.