In this article (7 sections)
Base64 turns binary data, such as an image, into plain text. That lets you paste a picture directly into HTML, CSS, JSON or an API request without a separate file. It is handy in some situations and a bad idea in others, and the deciding factor is the price in size.
What Base64 is
Base64 represents bytes using 64 printable characters. Every 3 bytes of data become 4 characters, so the text is about a third bigger than the file it came from. Here is what that looks like:
| Image size | Base64 text length |
|---|---|
| 1 KB (1,024 bytes) | 1,368 characters |
| 10 KB | 13,656 characters |
| 100 KB | 136,536 characters |
| 1 MB | 1,398,104 characters |
A data URI is the Base64 text with a short prefix that says what it is, for example data:image/png;base64, followed by the characters. A browser can use that in place of a file address.
What the tool gives you
The Image to Base64 tool converts an image into text and also decodes Base64 back into an image. It produces five ready-to-use outputs:
- A data URI for use anywhere a URL is allowed.
- The raw Base64 string, without a prefix, for APIs.
- An HTML img tag with the data URI inside.
- A CSS background-image line.
- A Markdown image.
It shows the size increase and warns when an image is too large to inline sensibly. It can also detect the image type of pasted Base64 that has no prefix. Everything runs in your browser; the image is not uploaded. The limit for the input is 10 MB.
When embedding makes sense
- Tiny icons and spinners. A very small image saves a request and arrives with the page.
- Email templates. Some email setups handle inline images, though many clients block or strip data URIs, so test before you rely on them.
- Single-file demos and documents. An HTML file with its image inside is easy to share.
- APIs that expect Base64. Many accept an image as a Base64 string in a JSON body.
- Test data and snippets. A short string is easier to paste into code than a file.
When not to embed
- Photographs and large images. Base64 makes the data about a third larger and it cannot be cached separately, so the browser downloads it again with every page. A normal image file is better.
- Anything used on many pages. A file is fetched once and cached; embedded text is repeated.
- Content that needs to be indexed or reused. Search engines and other tools handle files better than inline text.
Make the image small first
Shrink the picture before encoding it: resize it with the Image Resizer and compress it with the Image Compressor or Compress Image to 20 KB. For simple icons, an SVG is usually smaller than any bitmap and can be embedded as text directly. If you need a bitmap version of an SVG, use SVG to PNG.
Decoding
To turn a Base64 string back into an image, paste it into the tool. You can paste the whole data URI or just the characters, and the tool detects the type so you can download the file. This is useful when an API returns an image as text.
Not encryption
Base64 is an encoding, not a security measure. Anyone can decode it in a second, so never use it to hide anything. The same warning applies to Base64 in other contexts, such as the encoders in the Developer Tools category.
Related Tools
Image to Base64
Convert images to Base64 encoded strings.
JSON Formatter
Format, beautify, and validate JSON data with proper indentation.
Base64 Encoder Decoder
Encode and decode Base64 strings instantly.
HTML Formatter
Format and beautify messy HTML code with proper indentation.
Ready to try it yourself?
Use the free Image to Base64 — no signup, runs entirely in your browser.
FreeToolsVerse Team
We build free online tools and write the guides that explain how they work. No sign-up needed.