Skip to content

Encoding

Image to Base64

Encode a PNG, JPEG or WebP file as a complete Base64 data URI for HTML or CSS.

How to use this tool
  1. Choose an image up to 5 MB.
  2. Encode the image as a data URI.
  3. Copy the URI into your HTML or CSS.

Loading tool…

Helpful references

About this tool

What is Image to Base64?

Embed a small local image as a complete data URI when a destination cannot refer to a separate image file. The result includes the media type, encoding marker and encoded file bytes. This can simplify a small self-contained example, but it increases text size and makes the image part of the containing document rather than an independently cached resource.

A worked example

Recognize the prefix required by an HTML image

Example input

badge.png

Expected result

data:image/png;base64,…

The abbreviated output illustrates the prefix, not a complete image. Copy the full generated value into a src attribute or the contents of a CSS url function. Bare Base64 bytes without the media-type prefix are not a complete data URI. A 3,000-byte input needs 4,000 Base64 characters before the prefix; encoding does not compress the image.

Common mistakes and limits

  • Large inline pictures inflate HTML or CSS and cannot be cached separately from their containing file. Prefer normal image URLs for substantial website assets.
  • The encoded content remains the original file data. Base64 does not conceal the picture, remove metadata or provide access control.

Features

What you can do

  • Actual image file encoding, rather than text encoding
  • Complete data URI ready for src or CSS url()
  • Copy or download the encoded source

Frequently asked questions

Questions about Image to Base64

What should I know before using this tool?

Base64 increases size and is not encryption. The original file bytes, including metadata, are preserved. Large data URIs can make pages slower; use regular image files when appropriate.

Related tools