Image to Base64

Convert images to Base64 strings, Data URI, HTML and CSS code

Browser-based processing, images never uploaded
Drag image here, click to select, or Ctrl+V to paste
Supports JPG, PNG, WebP, GIF, BMP. Max 50MB
preview
Base64 String
Data URI
HTML Code
CSS Code

What is Image to Base64?

Image to Base64 is the process of encoding an image file into a Base64 string. Base64 is an encoding scheme that represents binary data using 64 printable ASCII characters. The converted string can be directly embedded in HTML, CSS, or JSON without requiring separate image file requests.

Base64 encoding is widely used in web development, data transmission, and embedded images. This tool converts images to Base64 strings, Data URIs, HTML img tags, and CSS background code for easy embedding.

Use Cases

Image to Base64 conversion is useful in the following scenarios:

  • Embed small icons in CSS to reduce HTTP requests
  • Embed images in HTML emails (email clients don't support external image references)
  • Store image data in JSON or databases
  • Quick image preview in code
  • Generate ready-to-use HTML img tags or CSS background code

FAQ

How much larger does the file get after Base64 encoding?

Base64 encoding increases data size by approximately 33%. For example, a 3KB image becomes about 4KB after encoding. Therefore, it's recommended to only use Base64 embedding for smaller images like icons and small decorations.

Are images uploaded to a server?

No. All conversions are done locally in your browser using FileReader API and Canvas API. Images are never uploaded to any server.

Can I choose different output formats?

Yes. You can re-encode images as PNG, JPEG, or WebP format. JPEG and WebP also support quality adjustment, allowing you to balance between file size and image quality.

Can the generated code be used directly?

Yes. The tool provides four output formats: raw Base64 string, Data URI (can be used directly as src), HTML img tag code, and CSS background-image code. Simply copy and use.