Skip to content
YouNeed Tools
Free VPN

Image to Base64

Encode a picture as Base64 text for HTML, CSS, JSON, email templates or an API, in the exact form you need to paste.

Drop a picture to encode

PNG, JPG, SVG, WebP, GIF, ICO, AVIF or BMP. Small icons and logos suit Base64 best.

or drag and drop here

Which output to use

OutputExampleUse it for
Data URIdata:image/png;base64,iVBO…img src, JSON, JavaScript, anywhere an image address goes
CSS backgroundbackground-image: url("data:…");Icons and small patterns in a stylesheet
HTML img<img src="data:…" alt="…">Single-file HTML pages and HTML email signatures
Markdown![alt](data:…)Notes apps that accept data URIs
Base64 onlyiVBORw0KGgo…APIs and JSON fields that ask for “base64 image”

How big is too big?

Every character of Base64 travels with the page or stylesheet it sits in, every time, and is about a third bigger than the file. Under 10 KB of text, inlining usually pays off because it saves a separate request. Between 10 and 100 KB it works but rarely helps. Above that, link to an image file instead. SVG icons are often smallest as Base64 too, but plain SVG text in the CSS is smaller still if your setup allows it.

Worked example: a 1.2 KB icon

A 24 × 24 PNG icon of 1,230 bytes becomes 1,640 characters of Base64. As a CSS background it adds 1.6 KB to the stylesheet and saves one request: a good trade. A 350 KB photo would become about 467 KB of text, blocking the page until it loads, so the tool marks it in red.

Good to know

  • The picture type in the data URI comes from the file’s first bytes, not its name, so a PNG saved as “.jpg” is still labelled image/png.
  • Gmail and some other email apps block data-URI images; for newsletters, host the image and link to it.
  • Shrink the picture first: Resize image to the size it is shown at, then compress it, and the Base64 shrinks with it.

Frequently asked questions

How do I convert an image to Base64?
Choose the picture and the Base64 text appears at once. Pick the form you need (a data URI, a CSS background, an HTML img tag, Markdown or the bare Base64), then copy it or download it as a .txt file.
What is a data URI?
A way to put a whole file inside text, in the form data:image/png;base64,iVBORw0…. Anywhere a picture’s address is expected (an img src, a CSS url(), a JSON field) you can paste a data URI instead, and no separate file is needed.
Why is the Base64 bigger than my file?
Base64 writes every 3 bytes as 4 characters, so the text is about 33% larger than the file. That is why it suits small icons and logos best, and why the tool warns you about large pictures.
Should I inline images as Base64 on my website?
For tiny images (under about 10 KB) it saves a separate request. For bigger ones it usually slows the page: the text can’t be cached on its own, it blocks the CSS or HTML it sits in, and it is a third larger. Use normal image files there, compressed with Compress image.
Is the picture changed?
No. The file’s bytes are encoded exactly as they are, so decoding the text gives back the identical file, including any photo info inside it. To strip that first, use Remove EXIF data.
How do I turn Base64 back into a picture?
Paste it into Base64 to image, which shows the picture and saves it with the right file type.

Last updated: 2026-11-26