Need an image inside your code or stylesheet? Paste it here and get a Base64 data URI, raw Base64, an HTML img tag, or a CSS background — ready to copy.
Image to Base64 Converter
Use this free image to base64 converter and base64 data uri generator to convert image to base64 strings (PNG, JPG, WebP, GIF, SVG) in your browser — copy the data URI, HTML tag or CSS with zero uploads.
Base64 inflates size by ~33% (4 ASCII characters per 3 bytes). Best for small icons under ~10 KB; keep large photos as linked files.
Embed this tool on your website
Copy the snippet below or use shortcode [ted_image_to_base64] in WordPress.
<iframe src="https://tinyexe.com/image-to-base64/?tinyexe_embed=1" width="100%" height="680" style="border:0;border-radius:14px" loading="lazy"></iframe>
Related tools
How to convert an image to Base64
- Drop your image file. Add a PNG (`png to base64`), JPG (`jpg to base64`), WebP, GIF or SVG into this base64 image encoder.
- Choose an output format tab. Switch between Data URI (`image to data uri`), Raw Base64, HTML `
` snippet (`embed image in html`), or CSS `background-image`.
- Copy or download as .txt. Click Copy or save the encoded text from this base64 encode image online tool.
How it works
Base64 turns every 3 bytes of binary data into 4 printable ASCII characters (A–Z, a–z, 0–9, +, /) with = padding, per RFC 4648. A data URI (defined in RFC 2397) prepends the MIME type header — such as data:image/png;base64, — so a web browser can render the string anywhere it expects an image URL.
Encoding is performed directly by your browser's native FileReader.readAsDataURL() API with no external library and no server upload. Decoding the string reproduces the original file byte-for-byte; the re-encoding itself is lossless, though the resulting text is roughly 33% larger than the binary file.
Worked examples
1. 1×1 red-dot GIF
Raw Base64: R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=. Data URI: data:image/gif;base64,R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=. HTML tag: <img src="data:image/gif;base64,R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=" alt="red dot">.
2. Small PNG icon (~6 KB → ~8 KB text)
PNG Base64 strings always start with iVBORw0KGgo (from the 8-byte PNG signature), JPEG strings start with /9j/, and WebP strings start with UklGR.
3. 200 KB JPEG photo (~267 KB text — why NOT to inline)
A 200 KB photo balloons to ~267 KB of inline HTML/CSS text that cannot be cached separately from the document. Keep photos above roughly 10 KB as normal linked image files.
Base64 output formats compared
| Output format | What you get | Best for |
|---|---|---|
| Data URI | data:image/png;base64,… | HTML src, CSS url(), anything expecting a URL |
| Raw Base64 | Just the encoded string | JSON fields, config files, APIs |
HTML <img> tag | Ready-to-paste <img src="…"> | Dropping an icon into a page |
| CSS background | background-image: url("…"); | Icons and small graphics in stylesheets |
What the tool does NOT do
This tool does not compress, resize or optimise your image — a PNG stays a PNG and a JPEG stays a JPEG at the exact same byte quality. It does not make large images suitable for inlining: Base64 inflates size by ~33%, so photos, banners and anything above roughly 10 KB should remain external linked files. Finally, this tool encodes images to Base64 only; for text Base64 encoding and decoding, use our Base64 Encode/Decode tool.
Frequently asked questions
Is the image to Base64 converter free?
Yes. Free, no sign-up, no limits beyond the 4 MiB per-file cap.
How do I convert an image to Base64?
Drop the image, pick an output format, copy the result. The data URI is ready to paste into an src attribute or CSS.
What is a Base64 data URI?
A text string starting data:image/png;base64, (or the matching MIME type) that contains the whole image, so a browser can display it without a separate file or network request.
Are my images uploaded anywhere?
No. Encoding runs entirely in your browser with the FileReader API; the file never leaves your device.
Why is the Base64 string bigger than my image?
Base64 uses 4 characters for every 3 bytes, so the text is about 33% larger. A 30 KB image becomes roughly a 40 KB string. That is expected, not a bug.
What image formats are supported?
PNG, JPG/JPEG, GIF, WebP, SVG, AVIF and BMP — anything your browser recognises as an image. The MIME type comes from the browser's own detection.
Can I convert a JPG to Base64?
Yes. Drop the JPG and copy the data URI; JPEG Base64 strings start with /9j/.
Can I convert a PNG to Base64?
Yes. PNG Base64 strings start with iVBORw0KGgo.
What is the difference between raw Base64 and a data URI?
Raw Base64 is just the encoded data. A data URI adds the data:[mime];base64, prefix so it works directly as an image URL.
Should I Base64-encode a large photo?
No. Use it for small icons and logos (roughly under 10 KB). Large photos become huge strings that slow the page down and defeat caching — link the file instead.
Can I use the data URI in CSS?
Yes. Paste it inside url("…") as a background-image. The tool's CSS output format gives you the ready-made rule.
Does Base64 encoding lose quality?
No. It is a lossless re-encoding of the exact bytes; decoding gives back the identical file. It does not compress or change the image at all.
