How to convert an image to Base64
- Drop up to 20 images onto the box above, choose them with the button, or paste one from the clipboard.
- Choose the Output, such as Data URL, Base64 only, HTML <img>, CSS background or Markdown.
- Select Copy, or Download .txt to save the text as a file.
Encoding an image as a Base64 string or data URI
This Base64 encoder converts an image to Base64—whether you need PNG to Base64, JPG to Base64, SVG to Base64 or an image to data URL (also called a data URI)—and wraps the Base64 image in the code you need: a data URL, an HTML img tag, a CSS background-image line or a Markdown image. Change the Output and every result changes with it, so you can convert an image to Base64 in each form without adding the files again. The type in a data URL comes from the file, such as image/png or image/svg+xml, and the HTML and Markdown forms use the file name as the image’s description, which you can change after pasting.
When to use Base64 images in code
| Use | Why |
|---|---|
| Small icons in CSS or HTML | One file fewer to load |
| Email templates | The image travels with the message |
| JSON and config files | Text-only formats can carry an image |
| Tests and examples | The picture lives inside the code |
Large photos are better left as files: the text is about a third bigger and is loaded again with every page. Make images smaller before encoding them with Compress image, turn an SVG into a PNG with SVG to PNG, validate a JSON payload containing a Base64 string with the JSON formatter, or change the format with Image converter.
Use the Base64 decoder to encode plain UTF-8 text or decode raw Base64 text. Use this image tool for Data URLs and image embed snippets.
Frequently asked questions
Are my images uploaded?
No. Each file is read and encoded in your browser. Nothing is sent to a server.
Why is the Base64 text bigger than the image?
Base64 writes every 3 bytes as 4 letters, so the text is about a third larger than the file. The page shows both sizes.
Which images can I use?
Any image file up to 50 MB, including SVG, GIF, ICO, WebP and AVIF, 20 at a time. The file is copied exactly, so animations and transparency stay.
What is a data URL?
It is the image as text, with its type in front, such as data:image/png;base64, followed by the Base64. You can use it wherever a link to an image would go, in an img tag or a CSS url().
Why do I see only part of the text?
Results over 1 MB show their first 2,000 characters on the page, so the page stays quick. Copy and Download .txt always give you all of it.
Last updated November 10, 2026