◈

Image to Base64

Convert image to base64 using the available input and format options.

Choose a file or fill the fields, then click Convert to Base64.

About Image to Base64

Developers sometimes need an image as text: an icon inlined in CSS, a small logo embedded in an HTML email, or test data in a JSON fixture. A data URL avoids a separate file request. This tool turns a chosen image into that text string so you can paste it straight into code.

How it works

The image is drawn onto a canvas and exported with toDataURL in the same type as the file, so the output starts with a prefix such as data:image/png;base64, followed by the encoded pixels. The full string appears in the result box and can be saved as image.b64.txt. Note that this is a re-encoded copy, not the original bytes: JPEGs are compressed again, metadata is dropped, and formats the browser cannot encode, such as GIF, come out as PNG data. Everything stays on your device.

How to use Image to Base64

  1. Choose the file required by this tool (image).
  2. Select “Convert to Base64” and check the result before copying or downloading it.

Worked example

A 32x32 PNG icon of 1.1 KB produces a string that begins data:image/png;base64,iVBORw0KGgo and runs to roughly 1,500 characters, because Base64 adds about one third to the size. You can drop it into CSS as background-image: url(...) with the string inside the parentheses.

Tips for a better result

  • Inline only small images such as icons under a few kilobytes. Large Base64 strings bloat HTML and CSS and cannot be cached separately.
  • Use the Copy button rather than selecting by hand. Long strings are easy to truncate, and one missing character breaks the image.
  • If you need the exact original file bytes, for example to verify a checksum, this canvas-based output will not match them.

Frequently asked questions

Why is the Base64 text bigger than my file?

Base64 represents every 3 bytes as 4 text characters, so output is about 33 percent larger. A re-encoded JPEG can also differ in size from the original file.

Does the string include the data: prefix?

Yes. The output is a complete data URL with the MIME type, such as data:image/jpeg;base64, so it works directly in an img src or CSS url(). Remove the prefix if your system wants raw Base64 only.

Is my image uploaded to create the string?

No. The browser reads the file, draws it on a canvas and builds the string locally. Nothing is sent to a server during encoding.

What to check

Conversion can change image quality, dimensions, format support or metadata. Keep the original file.

Read the Privacy Policy for information about local processing, connected services and advertising.