Type a tool name, for example "keyword density" or "transcript".
Select an image file to convert it into a Base64 encoded string. Supports JPEG, PNG, GIF, WebP, SVG, and more.
Drag & drop an image here or click to browse
Max 10 MB. All common image formats supported
Image to Base64 is a free online converter that turns a picture into a text string you can paste straight into code. Upload a JPG, PNG, GIF, WebP or SVG file up to 10 MB, and the tool gives you the Base64 string, a ready-made HTML image tag and a CSS background rule.
Base64 image encoding represents the binary bytes of an image file as plain text built from 64 safe characters: A to Z, a to z, 0 to 9, plus and slash, with equals signs as padding. Because the result is text, you can place it inside HTML, CSS, JSON or a JavaScript variable instead of linking to a separate file.
Every 3 bytes of the image become 4 text characters, so the encoded string is about 33% larger than the original file. The picture itself does not change. Decoding the string returns the identical image, so no quality is lost.
On a web page the string is usually wrapped in a data URI, which starts with data:image/png;base64, and is followed by the encoded text. That prefix tells the browser the file type, so it knows how to draw the image.
You can convert an image to Base64 in a few clicks, and you do not need an account. Follow these steps:
Say you have a PNG logo that is 200 x 60 pixels and 24 KB. After you click Convert to Base64, the results panel shows the format as PNG, the dimensions as 200 x 60 and the file size as 24.0 KB, and the preview shows your logo.
The encoded text will be roughly 24 x 4 / 3 = 32 KB. That is a small cost for an icon-sized graphic, and you save one file request. Copy the HTML Image Tag and paste it into your page, and the logo appears with no image file to host.
Now compare a 1.2 MB photo. Its encoded text would be about 1.6 MB, which would bloat your HTML and slow the page. In that case, shrink the picture first with the image compressor or the image resizer, or keep it as a normal file.
The results panel has two parts: details about the file you uploaded and three output tabs. Use the details to confirm you have the right image, then pick the tab that fits where the code is going.
| Tab | What you get | Best for |
|---|---|---|
| Base64 String | The encoded text | JSON, scripts, APIs, app code |
| HTML Image Tag | An image element with the data embedded | Web pages and templates |
| CSS Background | A background rule with the data embedded | Icons, patterns, small textures |
The Format field confirms the real file type, which matters because a data URI must name the correct type. The Dimensions field tells you the pixel size, so you can set matching width and height in your markup and avoid layout shift. The File Size field is the original size, so multiply it by about 1.33 to estimate the encoded length.
A common rule of thumb is to inline only small images, often those under roughly 10 KB, such as icons, tiny logos and simple patterns. Between 10 KB and 100 KB, think about whether the saved request is worth the heavier page. Above that, a normal image file is usually the better choice.
The Base64 String tab is what you paste into a JavaScript variable, a JSON field, a Python script, a React component or a Flutter project that expects an image as text. When the code goes into an src attribute or a CSS url(), the value must be a complete data URI that starts with data: and the image type. The HTML Image Tag and CSS Background tabs are built for direct pasting, so they are the safest starting point.
Convert an image to Base64 when you need the picture to travel inside a block of text rather than as a separate file. These are the situations where it helps most:
If you only need a stand-in picture while designing, the placeholder image generator can create one at any size, and you can then encode it here.
Base64 adds about a third to the size, and the text cannot be cached separately from the page it sits in. Resize the picture to the exact display size and compress it first. A 400-pixel-wide icon displayed at 80 pixels wastes most of its bytes.
Search engines find images through their file URLs, so an image embedded as text has no address of its own for image search. Keep product photos, article images and anything you want to rank as normal files with descriptive file names and alt text.
If the image is blank after pasting, first check that the snippet was copied in full, because very long strings are easy to cut off. Then confirm there are no stray spaces or line breaks inside the string. Last, make sure the type after data:image/ matches the real format shown in the Format field.
To verify a string from this tool or from someone else, paste it into the Base64 to image converter. If the preview matches your original, the encoding is intact.
The converter handles one image at a time, and each file must be 10 MB or smaller. It encodes your file exactly as it is: it does not resize, compress or edit the picture. A large file will produce a very long string that some editors, databases and API fields may struggle to hold. Base64 is also an encoding, not encryption, so anyone can decode the string back into the image.
For a broader set of tools to prepare pictures before encoding, browse the image editing and optimization tools.
Upload your picture above, click Convert to Base64, and copy the string, image tag or CSS rule you need. Optimize the image first if it is larger than a few kilobytes, and your page will stay fast.
Your report has been submitted. We will look into this issue.
A VPN changes your network exit. It does not guarantee anonymity.
Themes, plugins, code, video, audio, graphics & more from 90,000+ authors.
Web Development
Design & Media
Unlimited Access
Explore Envato Market