Image to Base64 Converter

This image to Base64 converter turns a picture into a Base64 string you can copy straight away as a data URL, HTML tag, CSS background, Markdown or JSON. It can shrink the image or convert it to PNG, JPG or WebP first. In the other direction, the decoder shows the image behind any Base64 text and saves it as a file.

Source: RFC 2397, RFC 2397 – The "data" URL scheme. Updated: .

Drag and drop files here or

One image (JPG, PNG, GIF, WebP, SVG, ICO …), up to 10 MB

Tip: you can also paste images with Ctrl + V.

Your files are processed only in your browser and never uploaded – they don’t leave your device.

Base64 code

Choose an image – the Base64 code will appear here.

My Toolbox

Result

How it is calculated

How to convert an image to Base64

  1. Drag in an image, choose it or paste it with Ctrl + V. The Base64 code appears immediately.
  2. Pick the output: a data URL for src or url(), Base64 only for APIs, a ready-made HTML img tag with width and height, a CSS line for background-image, Markdown or JSON.
  3. Copy it or save it as a text file.

A data URL follows RFC 2397: data:image/png;base64, followed by the image bytes in Base64 as defined in RFC 4648. The MIME type is detected from the file content, not the extension, so a PNG named .jpg still gets image/png.

How big does an image get in Base64?

Base64 turns every 3 bytes into 4 characters, so the text is about 33% larger than the file: a 30 KB image becomes roughly 40,000 characters. That is why Base64 is best for small graphics such as icons, logos, placeholders in emails, self-contained HTML files and CSS. Shrink large photos first with “Resize to width”, or convert them to WebP or JPG.

Base64 back to an image

In “Base64 → image” mode, paste a data URL, a whole CSS line, an HTML img tag or just the Base64 text – with line breaks, without the trailing equals signs or in the URL-safe variant with - and _. The tool recognises JPG, PNG, GIF, WebP, BMP, TIFF, AVIF, HEIC, SVG and ICO, shows the size and dimensions and saves the file with the right extension. If the type in the data URL does not match the actual content, you get a note.

Privacy and limits

Images and pasted text stay in your browser; nothing is uploaded or stored. Images up to 10 MB can be encoded; SVG and ICO are kept as they are. To encode any text or file, use Base64 encode and decode; to change an image’s format, the image converter, and to make it smaller, compress the image.

Frequently asked questions

How do I convert an image to Base64?

Choose the image here and the code appears instantly. As a data URL it starts with data:image/…;base64, and can be used directly in HTML or CSS.

How do I embed a Base64 image in HTML?

Choose the “HTML ” output and copy it: <img src="data:image/png;base64,…" alt="…">. The tool adds width and height for you.

How do I convert Base64 back to an image?

Switch to “Base64 → image”, paste the text and click “Show image”. The picture appears and can be saved with the correct file extension.

Why is the Base64 string bigger than the image?

Base64 represents every 3 bytes with 4 text characters, so the string is about one third larger than the image file.

Can I convert an SVG to Base64?

Yes. SVG is encoded unchanged with the type image/svg+xml, for example for CSS backgrounds.

Is my image uploaded?

No. Encoding and decoding run entirely in your browser, and nothing is stored.

Sources and legal basis

As of: · Editorial policy

Related tools