Image ↔ Base64

Input

Drop image here or click to upload

PNG, JPG, GIF, WebP supported

Base64 Output
100% Client-Side • Zero Data Sent to Servers

Online Image to Base64 Converter & Data URI Encoder

Convert image files into Base64 encoded strings (Data URLs) for direct embedding into CSS, HTML, and JSON, or decode raw Base64 back into downloadable image files.

Local Processing & Data Privacy

All formatting, parsing, decoding, and validation executes entirely within your browser using modern Web APIs and JavaScript. Your tokens, JSON payloads, regex inputs, and queries never leave your computer.

About this Tool

Embedding small graphic assets—such as icons, UI logos, and avatar placeholders—directly into HTML or CSS using Data URIs eliminates external HTTP requests, reduces latency, and guarantees self-contained assets in emails and offline web apps.

DevRef's Image to Base64 Converter handles bidirectional encoding and decoding. Drag and drop any PNG, JPG, WebP, or SVG file to receive a standards-compliant data:image/...;base64,... string, or paste a Base64 string to render and download the original graphic. All conversions use browser FileReader APIs with zero server transmissions.

How to Use

  1. 1Upload Image or Paste Base64: Drag and drop your graphic into the encoder, or paste a Base64 string into the decoder tab.
  2. 2Select Output Format: Choose 'Data URI' (for HTML img src or CSS background-image) or 'Raw Base64' (for JSON API payloads).
  3. 3Inspect Image Preview: Review the rendered preview, mime type, and exact string length in bytes.
  4. 4Copy or Download: One-click copy the Data URI snippet or download the decoded image file.

Key Features

  • •Bidirectional conversion: Image to Base64 and Base64 back to Image
  • •Ready-to-use snippets for HTML <img>, CSS url(), and raw API payloads
  • •Supports PNG, JPG, WebP, GIF, SVG, and ICO formats
  • •Detailed payload size analysis (including the ~33% Base64 encoding overhead)
  • •100% private in-browser encoding: graphics and tokens never leave your browser

Frequently Asked Questions

Why is a Base64 string larger than the original image file?

Base64 represents 3 binary bytes as 4 ASCII characters, introducing a consistent ~33% size overhead compared to binary files. It is best used for small icons (<10KB) where eliminating HTTP connection overhead outweighs the slight payload increase.

How do I use a Data URI in CSS?

Use the syntax: background-image: url('data:image/png;base64,iVBORw0KGgo...'); which embeds the icon directly into your stylesheet.

Are my uploaded images or decoded data sent to DevRef?

No. The FileReader and Canvas APIs execute entirely within your client's web browser. No data is sent over the network.