Image to Base64 Converter
Encode and Decode, Privately
Turn an image into a Base64 string or data URI for HTML, CSS and Markdown, or decode a Base64 string back into an image.
Image → Base64
or click to browse · any image up to 20 MB · or paste
Base64 → Image
More free tools
How it works
Add an image
Drag and drop, browse or paste an image up to 20 MB.
Choose a format
Pick data URI, Base64 only, HTML, CSS or Markdown and click Copy.
Or decode
Paste a Base64 string in the second box to preview and download the image.
What is Base64 for images?
Base64 represents binary data such as an image as plain text. A data URI such as data:image/png;base64,… lets you put a small image directly inside HTML, CSS, JSON or an email, without a separate file or request.
When to use it, and when not to
- Good for: tiny icons, placeholders and images in a single-file page or email template.
- Avoid for: large images. Base64 is about 33% larger than the file, cannot be cached separately and bloats your HTML or CSS. Use normal image files for photos.
Decoding Base64 back to an image
Paste the string with or without the data:image/…;base64, prefix. The tool recognises PNG, JPG, GIF, WebP and SVG, shows a preview and lets you download the file. Invalid strings are reported instead of failing silently.
When developers use Base64 images
Developers use Base64 data URIs for tiny icons in CSS, self-contained HTML reports, email templates, API payloads and prototypes. This tool outputs ready-to-paste snippets for HTML, CSS and Markdown, and decodes Base64 strings back to images for inspection. Before embedding, shrink the image with the PNG compressor or resizer because Base64 adds about 33%.
Related reading
Learn when inline images help or hurt in Base64 images and data URIs, and how loading affects speed in Core Web Vitals image optimisation.
Frequently asked questions
<img src="data:image/png;base64,…">.Guides and tutorials
- Base64 Images and Data URIs: When They Help and When They HurtWhat Base64-encoded images and data URIs are, how to use them in HTML and CSS, their 33% size overhead and when inline images help or hurt performance.
- Image Optimization for Core Web Vitals: Fix LCP and CLSHow images affect LCP and CLS, with fixes: right size and format, fetchpriority, no lazy-loading the hero, and set dimensions on every image.
- Responsive Images in HTML: srcset, sizes and the picture ElementLearn how srcset, sizes and the picture element let browsers load the right image for each screen, with copy-paste examples and common mistakes.