Image to Base64

Everything runs in your browser. Your data never leaves your device.

What this tool does

This tool converts an image into Base64 text that you can paste straight into code. Choose a JPG, PNG, WebP, GIF or SVG file and copy the result as a complete data URL, as Base64 only, as an HTML <img> tag, as a CSS background-image rule, or as a Markdown image. The character count updates for each format.

How to use it

  1. Choose, drop or paste an image.
  2. Pick the output you need under Output.
  3. Press Copy and paste it into your HTML, CSS, JSON or Markdown file.

How it works

A data URL has three parts: data:, the file type (for example image/png), and ;base64, followed by the encoded file. Every 3 bytes of the file become 4 characters from a 64-character alphabet (A–Z, a–z, 0–9, + and /), with = padding at the end when needed.

Example: a 1,000-byte PNG icon becomes 1,336 Base64 characters, plus 22 characters for data:image/png;base64, in front.

When to use Base64 images

To encode or decode text rather than images, use the Base64 text encoder linked below.

Frequently asked questions

What is a Base64 image?

It is the image file written as plain text, so it can be placed directly inside HTML, CSS, JSON or an email instead of being loaded from a separate file.

Why is the Base64 text bigger than the image?

Base64 uses 4 text characters for every 3 bytes of the file, so it is about 33% larger. That is why it suits small icons and logos better than photos.

Is the image changed or compressed?

No. The tool encodes your original file byte for byte, so decoding the text gives back exactly the same image.

Is my image sent to a server?

No. The encoding happens in your browser, and the image never leaves your device.

Last updated: · What's new

Related tools