Image to Base64

Get the Base64 text or data URL of an image.

About this tool

Sometimes a small image needs to travel as text, for example inside a CSS file, an HTML page, an email template or a JSON payload. Base64 does that by writing the image bytes using 64 safe characters. This tool reads an image you choose and shows its Base64 text and the full data URL, which begins with data:image/png;base64 or a similar prefix and can be used directly as the source of an image in HTML or CSS. You can copy either form with one tap. The page also shows the original size and the size of the Base64 text, which is about a third larger than the file. Embedding large images this way makes pages heavier and slower, so it suits small icons and logos best. The file is read inside your browser by the page code, and nothing is uploaded.

How to use it

  1. Choose an image from your device.
  2. Check the preview and the size information.
  3. Tap Copy Base64 for the raw text, or Copy data URL for the full string with its prefix.
  4. Paste it into your HTML, CSS or JSON.
  5. Compress large images first so the text stays short.

How it works

The browser reads the file with FileReader.readAsDataURL, which returns data:[type];base64,[text]. Base64 maps every three bytes to four characters, so the text is about 33 percent longer than the original file.

Example: A 3 KB PNG icon becomes about 4 KB of Base64 text. In HTML it can be used as <img src="data:image/png;base64,..."> where the dots stand for the copied text.

Common uses

  • Embedding a small logo in an HTML email template.
  • Putting an icon directly into a CSS file to save a request.
  • Including a picture in a JSON test payload.

Frequently asked questions

What is the difference between Base64 and a data URL?
Base64 is just the encoded text. A data URL adds a prefix such as data:image/png;base64, so it can be used directly as an image source.
Is Base64 a good way to put images on a website?
Only for very small images. Large embedded images make the page heavier and cannot be cached separately.
Is my image uploaded?
No. The page code reads the file in your browser and does not send it anywhere.
Why is the text longer than my file?
Base64 uses four characters for every three bytes, which makes it about a third larger.

Last reviewed 2026-11-01. Browse all tools