AnyTool
Your files never leave your device. All processing happens locally in your browser.

How do I convert an image to Base64 (and back)?

Drop an image onto AnyTool to get its Base64 string and full data: URI instantly, with ready-to-copy HTML, CSS, and Markdown snippets. Paste a Base64 string or data URI to decode it back to a viewable, downloadable image — all in your browser with no upload.

  • Encode any image to raw Base64 and a full data: URI
  • Decode Base64 / data URI back to a viewable, downloadable image
  • Copy as HTML <img>, CSS background-image, or Markdown ![alt]
  • Size readout: bytes, Base64 length, ~33% overhead, and pixel dimensions
  • 100% in-browser — images never leave your device, no size cap

What is

Base64 Image (Data URI)

A Base64 image, or data URI, encodes an image's bytes as a text string of the form data:image/png;base64,… so it can be embedded directly in HTML, CSS, or Markdown without a separate file request, at the cost of roughly 33% more size than the binary original.

Developer Tools

Related terms

Data URIBase64 EncodingMIME TypeInline ImageFileReader

Frequently Asked Questions

Yes — encode an image to Base64 and decode Base64 back to an image on the same page.

Most converters split encode and decode across separate pages, but this tool does both: drop a file to get its Base64 and data URI, or paste a Base64 string or data URI to render and download the original image. If you paste raw Base64 with no data: header, it sniffs the magic bytes to infer the MIME type and still renders it.

Raw Base64, full data URI, HTML, CSS, and Markdown snippets, plus size and dimension stats.

For each image it produces the raw Base64, the full data: URI, an HTML <img> tag, a CSS background-image rule, and a Markdown image snippet — the Markdown output most rivals omit. It also shows the original byte size, decoded bytes, Base64 character length, the ~33% encoding overhead, and the pixel width and height.

No — encoding and decoding run entirely in your browser.

It uses FileReader, canvas, and Blob APIs locally, so your image never leaves the browser and there is no server upload — unlike tools that POST your file or fetch a remote URL server-side. There is no fixed size cap beyond browser memory, and it works offline after first load.

Detailed Explanation

Methodology

How the Base64 Image Converter Works

AnyTool encodes images with FileReader.readAsDataURL, which yields the full data:<mime>;base64,… URI with the correct MIME type, and decodes with atob plus Uint8Array and Blob to render and download the original image. It emits ready-to-copy snippets — raw Base64, the data URI, an HTML <img> tag, a CSS background-image rule, and a Markdown image — and reports byte size, Base64 length, the ~33% overhead, and pixel dimensions. Pasting raw Base64 with no data: header triggers magic-byte sniffing to infer the MIME type so the image still renders.

  • Bidirectional encode and decode on one page
  • Output as Base64, data URI, HTML, CSS, and Markdown
  • Size, ~33% overhead, and pixel-dimension readout
  • Magic-byte MIME sniffing for headerless Base64
  • No fixed size cap beyond browser memory
Privacy & Security

Privacy and Offline Use

Encoding and decoding use FileReader, canvas, and Blob entirely in the browser with no runtime CDN, so images never leave the device — unlike converters that upload your file or fetch a remote URL server-side. The tool works offline after first load and has no signup.

Base64 Image: AnyTool vs typical converters
CapabilityAnyToolTypical converters
Encode and decode in one toolYesOften separate pages
Markdown image snippetYesRarely
Size + dimension readoutYesUsually none
Processing locationIn-browserSometimes server-side
File-size capBrowser memory onlyOften 1–10 MB

Capabilities reflect the live AnyTool tool; competitor behavior varies by service.