Free image tools

Convert an image to Base64 and a data URI

Encode an image file as Base64 text and copy it in the form you need: the raw string, a data URI, a CSS background rule or an HTML img tag.

This tool needs JavaScript. It runs entirely in your browser; nothing is uploaded.

Private by design. Your files are processed by your own browser on your own device. They are not uploaded, stored or seen by Archive.London. Tool terms

How to use the Image to Base64 tool

  1. Choose or drop an image file.
  2. Pick the output form: raw Base64, data URI, CSS or HTML img.
  3. Copy the encoded text and paste it into your code.

To convert an image to Base64, open the Archive.London Image to Base64 tool and choose or drop your image file. The tool encodes it in your browser. Copy the result as a raw Base64 string, a data URI, a CSS rule or an HTML img tag. The file is not uploaded.

When inlining an image as Base64 helps, and when it hurts

Base64 represents every three bytes of a file as four text characters, so the encoded text is about a third larger than the file. That overhead sets the rule of thumb: inline small images, link to large ones.

Good candidates are icons, small logos, placeholder graphics and images in HTML emails or single-file documents, where one self-contained file is the goal and an extra request is avoided.

Poor candidates are photographs. A large inlined image inflates the HTML or CSS that carries it, cannot be cached on its own, and is downloaded again whenever that file changes.

The four copy options cover the usual destinations: the raw string for APIs and JSON, a data URI for anywhere a URL is accepted, a ready-made CSS background declaration, and a complete HTML img element.

What Base64 is, and what a data URI looks like

Base64 is a way of writing binary data using 64 printable characters: the letters A to Z and a to z, the digits 0 to 9, plus the symbols + and /, with = used as padding at the end. It exists so that binary files can pass through systems designed for text.

A data URI wraps that text with a label saying what it is. It begins with the scheme and media type, for example data:image/png;base64,, and the encoded data follows. Browsers treat it like any other image address.

Base64 is an encoding, not encryption and not compression. Anyone can decode it, and it hides nothing. The encoding here is done by your browser on your own device, so the image is not sent to any server.

Images as text in datasets and catalogues

Base64 turns up well beyond web pages. Image records exchanged between systems as JSON often carry a thumbnail as an encoded string, and machine-learning pipelines commonly pass images to and from services in the same way, because text formats cannot hold raw binary.

The encoding changes how a picture is transported, not what it is or who owns it. A photograph encoded as text is still the same copyright work, and the caption, credit and licence terms need to accompany it in the surrounding record.

Archive.London sets out how the Robert Harper Photograph Library can be licensed for machine learning, by negotiation and subject to rights review, on its AI training data licensing page.

Frequently asked questions

What is a Base64 image?

It is an ordinary image file written out as text. Base64 encoding converts the file's bytes into letters, digits and a few symbols so the image can be embedded directly in HTML, CSS, JSON or an email. Decoding the text gives back the original file, byte for byte.

Does Base64 make an image file larger?

Yes. Base64 uses four characters for every three bytes of the original, so the encoded text is roughly 33 per cent bigger than the file. This is why it suits small images such as icons and is a poor choice for large photographs, which are better served as separate files.

How do I use a Base64 image in HTML or CSS?

Use a data URI in place of a file address. In HTML, put it in the src attribute of an img element. In CSS, put it inside url() in a background-image declaration. The tool can copy either form ready-made, so you can paste the complete tag or rule straight into your code.

Is Base64 encoding secure or private?

Base64 offers no security. It is a reversible encoding that anyone can decode in seconds, so it should never be used to hide or protect an image. The privacy of this tool comes from something else: the encoding is done in your browser, and the image is not uploaded.

Which image formats can I encode?

Base64 works on bytes, so it does not depend on the image format. Common web formats such as PNG, JPG, GIF, WebP and SVG are the usual choices, because the encoded image is only useful where a browser or program can display that format once it has been decoded.

About the archive behind this page

Archive.London is the home of the Robert Harper Photograph Library: 95,487 photographs made across a career that began in the Condé Nast studios.

Read the archive in factsWrite to the archive