Base64 Encoder & Decoder
Encode and decode text, files and images locally with Base64, Base64URL, MIME and Data URI support
Image to Base64
Drop, browse or paste an image. Nothing is uploaded.
Leave empty for original dimensions. GIF and SVG are kept unchanged.
Examples
Encode a 1×1 transparent PNG to a Data URI
image: 1×1 transparent PNG (67 bytes)data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGNgAAAAAgABXuWotAAAAABJRU5ErkJggg==The image grows from 67 bytes to 100 bytes once Base64-encoded (+49.3% overhead), with the standard data:<media-type>;base64,<payload> prefix prepended.
Generate the HTML snippet for the same PNG
data URI: data:image/png;base64,iVBORw0KGgo…g==
alt: logo<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGNgAAAAAgABXuWotAAAAABJRU5ErkJggg==" alt="logo" />The HTML tab wraps the Data URI in an `<img>` tag and HTML-escapes the alt attribute (&, ", <, > are encoded so the markup stays safe).
Generate the CSS snippet
data URI: data:image/png;base64,iVBORw0KGgo…g==background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGNgAAAAAgABXuWotAAAAABJRU5ErkJggg==");The CSS tab emits a `background-image` rule; double quotes around the URL match the snippets used by the JS escapeAttribute helper.
About this tool
The Base64 Image Encoder opens the Image workspace of Base64 Toolbox — drag, paste or browse for an image up to 10 MB and the tool returns a Base64 Data URI together with ready-to-paste HTML, CSS, Markdown and JavaScript snippets. The whole pipeline runs locally: nothing is uploaded, and image bytes are never sent off the device.
For raster images (PNG, JPEG, WebP) you can optionally resize the longest edge and adjust JPEG/WebP quality. SVG and GIF files are kept unchanged regardless of those settings so vector fidelity and animation are preserved. The preview panel reports the original and processed sizes, the encoded size overhead as a percentage, and the new dimensions when the image was resized.
The five snippet tabs cover the common cases: a raw Data URI for embedding directly in HTML; an `<img>` tag with the alt text you typed; a `background-image: url(...)` CSS rule; a Markdown `` image; and a `const imageDataUri = "…";` JavaScript assignment ready to drop into a module.
How to use this tool
Drop, paste or browse an image
Use the upload card to drag-and-drop, paste from the clipboard, or pick a file. PNG, JPEG, SVG, WebP and GIF are supported up to 10 MB.
Optionally resize and tune quality
Set the longest-edge limit (leave empty for the original size) and, for JPEG/WebP, drag the quality slider between 40 and 100%. SVG and GIF bypass these settings.
Set the alt text
Edit the alt field — the value is used verbatim in the HTML, Markdown and accessibility annotations of the generated snippets.
Copy the snippet you need
Pick the Data URI, HTML, CSS, Markdown or JavaScript tab and copy the corresponding block, or use Download URI to save the full Data URI to a file.
Use cases
Embedding small icons inline in HTML or CSS
Encode a logo or icon and inline the Data URI in an HTML email or a single-file CSS so the asset travels with the document.
Keeping prototypes self-contained
Skip a separate image request when prototyping — paste the Data URI into a static mockup and the asset renders without any server.
Pasting images into Markdown without uploading
Use the Markdown snippet to embed an image in a README, blog post or issue tracker that supports data: URLs.
Reducing the number of requests in a SPA
Inline tiny UI images (favicons, sprites, button states) to remove extra HTTP round-trips on slow connections.
Common mistakes
Mistake:Inlining very large images (>100 KB) as Data URIs.
Fix:Data URIs cost roughly +33% over the binary and block HTML parsing while decoding. Use them only for icons and small UI graphics; serve larger assets as separate files.
Mistake:Expecting GIF animation or SVG fidelity to survive a forced resize.
Fix:The tool refuses to resize SVG and GIF files — vector paths and frame timing would be destroyed. Pass them through unchanged or resize manually with a vector tool.
Mistake:Forgetting to update the alt text.
Fix:The alt field defaults to the file name minus its extension. Replace it with a meaningful description before copying the HTML or Markdown snippet so screen readers announce useful content.
Mistake:Treating the Data URI as encrypted.
Fix:Base64 is an encoding, not encryption — anyone can decode it back to the original image bytes. Do not use it to hide sensitive assets.
Frequently asked questions
What does the Base64 Image Encoder do?
It turns an image into a Base64 Data URI and generates ready-to-copy HTML, CSS, Markdown, and JavaScript snippets for embedding it.
Do resizing and quality settings apply to every image type?
They apply to raster images such as PNG, JPEG, and WebP. SVG and GIF files remain unchanged so vector fidelity and animation are preserved.
Is Base64 image encoding compression or encryption?
No. Base64 is an encoding format, not compression or security, and a Data URI is usually larger than the original image.
Is my data uploaded?
No. Images are processed locally in your browser and are never sent to a server.
Related guides
References & standards
Related tools
APCA Contrast Calculator
Calculate directional APCA 0.1.9 Lc contrast scores and compare them with WCAG 2.1 ratios.
Barcode Generator
Generate barcodes in 8 formats (CODE128, EAN13, UPC, and more) — configure line width, height, and text display, then download as SVG or PNG.
CSS Container Queries Lab
Generate CSS container queries and preview responsive component patterns
EXIF Viewer & Cleaner
View and remove EXIF metadata from images. See camera info, GPS location, and dates — then download a clean copy.
Favicon Pack Generator
Generate complete favicon packs with all standard sizes and Apple touch icons
Image Compressor
Compress JPEG, PNG, and WebP images in your browser. No uploads, completely private.