Image to Base64

Choose an image or drop it here, or paste it with Ctrl+V

What does “image to Base64” mean?

Base64 is a way of writing any file as plain text, using only letters, digits, plus and slash. A picture turned into Base64 is one long string that usually starts with data:image/png;base64, and carries the whole image inside it. You can paste that string where a file name would normally go: in an HTML page, in a style sheet, in an email, in a JSON file. The browser reads the text and draws the picture, with no separate download.

When is it worth doing?

For small things. An icon, a logo in an email signature, a tiny background pattern, a picture inside a single HTML file that you want to send as one attachment, or an image field in a JSON body when you are testing an API. You save a request and you cannot end up with a broken link.

Not for photos. A 300 KB photo becomes about 400 KB of text that the browser cannot keep in its cache separately, and it is downloaded again with every page that contains it.

Which format should I choose?

  • Data URL (with prefix) is the whole address, data:image/png;base64,…. It works in a src, an href and a CSS url(). Pick this if you are not sure.
  • Raw Base64 is only the characters after the comma. Use it when an API or a form asks for the Base64 and the type as two separate things.
  • HTML img src is a ready img tag with the width and height filled in, so the page does not jump when the picture appears.
  • CSS background-image is one line for a style sheet.
  • Markdown image is for a README or a note that shows Markdown.
  • JSON gives the type and the data as two fields, which is the shape many APIs expect.

Why is the text bigger than my file?

Base64 writes every 3 bytes as 4 characters, so the text is always about a third bigger. The tool shows the exact change under the box. Compressing the text afterwards, as a web server does with gzip, takes back a little but not much, because image files are already compressed.

The better saving is to make the picture smaller before you convert it: fewer pixels, or a lighter format such as WebP. Compress Image does that, and then you come back here.

Is my image uploaded?

No. The picture is read in your browser and turned into text on your own device. Nothing is sent anywhere, so a private screenshot or a logo that is not public yet stays with you.

How do I get the picture back?

Paste the text into Base64 to Image. It understands every format above, shows the picture and lets you download it as a file.