Images & Design

Image to Base64

Turn the original bytes of a small raster image into text. Copy a complete data URL, a raw Base64 string, or an HTML img element. Encoding happens locally and does not resize or re-encode the selected image.

Free online tool

Loading tool…

Encode a local image

PNG, JPEG, WebP, GIF, AVIF, or BMP; up to 24 megapixels. Original file bytes are encoded unchanged, including embedded metadata.

Choose the text format

Use a data URL where an image URL is accepted. Use raw Base64 for a field that already specifies the image type. HTML output uses a fixed alt attribute; replace it with a description before publishing.

Selected files are processed in your browser. This tool does not upload image bytes or fetch remote image URLs. Clear the tool to release its local image previews.

GET STARTED

How to use the Image to Base64

  1. 01

    Choose a supported raster image up to 5 MB and 24 megapixels.

  2. 02

    Review the image preview, dimensions, and encoded character count.

  3. 03

    Choose data URL, raw Base64, or HTML output.

  4. 04

    Copy the output or download it as a text or HTML file.

Examples

A small inline icon

Choose a small PNG and select the data URL output. The resulting string begins with data:image/png;base64, followed by the encoded file bytes.

An API field that expects Base64

Select raw Base64 when the receiving system has a separate MIME-type field. This removes only the data URL prefix; the encoded image bytes stay the same.

Base64 adds text overhead

Base64 represents each group of three bytes using four characters, with padding for incomplete groups. The exact encoded character count is 4 × ceil(bytes / 3). A data URL also adds a short media-type prefix.

Choose the correct wrapper

A data URL identifies the image MIME type and encoding. Raw Base64 contains only the encoded bytes. The HTML option wraps the data URL in an img element with a fixed alt attribute that should be replaced with useful alternative text.

Small assets work best

Large embedded images make documents and source files harder to read and can prevent independent image caching. This tool limits original files to 5 MB and rejects vector or non-image content. Base64 is an encoding, not encryption or access control.

What to know

  • Maximum original file size 5 MB and decoded size 24 megapixels.
  • The receiving website may restrict data URLs through its content security policy.

Common questions

Does Base64 compress an image?

No. Raw Base64 text is roughly one-third larger than the binary image, plus any data URL prefix.

Are metadata and animation retained?

The original file bytes are encoded unchanged, so embedded metadata and supported animation data remain in the output. Be careful with location metadata before sharing.

Can I paste the raw string into an img src?

An img src generally needs the complete data URL, including the media type and base64 marker. Use the data URL or HTML output option.

Is my image uploaded?

The tool reads and encodes the local file in your browser. It does not send the selected image to a conversion server.

Sources & references