Drawing Tool
Online Drawing Tool provides fast drawing experience for everyone to create digital artwork and download it as a JPG image.
Image to Base64 Converter is a free tool to convert images to Base64 encoding with Data URI, CSS background, HTML img tag, and plain Base64 output, and decode Base64 strings back to images.
There are situations where embedding an image directly into a stylesheet, an HTML file, or a JSON payload is genuinely more practical than referencing an external file. Eliminating an HTTP request for a small icon, making an email template self-contained, or packaging an image into a data structure that does not support file references are all real use cases where Base64-encoded images are the correct solution rather than a workaround.
This tool handles the conversion in both directions. Upload an image and get the Base64 output in the format your context requires. Paste a Base64 string and get the decoded image back. Everything runs in the browser.
Base64 is an encoding scheme that represents binary data as a string of ASCII characters. The name comes from the 64-character alphabet it uses: uppercase and lowercase letters, digits 0 through 9, plus and forward slash, with equals signs used for padding.
Binary image files contain byte values across the full 0 to 255 range, many of which correspond to control characters and non-printable values that cannot be safely transmitted as text. Base64 encoding solves this by converting every three bytes of binary data into four printable ASCII characters. The result is larger than the original by approximately 33%, but it can be safely embedded in any context that handles text: HTML attributes, CSS property values, JSON strings, XML documents, and email bodies.
A Base64-encoded image looks like a very long string of seemingly random characters. The actual image data is in there, fully intact and decodable by any Base64 decoder. It is not compressed or altered, just represented in a text-safe format.
The tool generates four distinct output formats from the same source image. Which one you need depends entirely on where the encoded image is going.
Data URI is the most complete and self-contained format. It combines the encoding scheme, the MIME type, and the Base64 data into a single string that can be used anywhere a URL is accepted. A JPEG Data URI looks like this:
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAA...
The browser reads the MIME type prefix, understands this is an image, decodes the Base64 data, and renders it exactly as it would render an image loaded from an external URL. Data URIs work in the src attribute of an <img> tag, as the url() value in CSS, and in any HTML attribute that accepts a URL.
Plain Base64 is just the encoded string without the MIME type prefix or scheme declaration. This is the format you need when the surrounding context already handles the MIME type declaration separately, when you are storing the encoded image in a database column, when you are embedding it in a JSON API response with a separate type field, or when you are passing it to a function or library that expects raw Base64 input.
CSS background wraps the Data URI in a background-image property declaration, ready to paste directly into a stylesheet:
background-image: url(""data:image/png;base64,..."");
This format is useful for icons, textures, and decorative images that are applied as CSS backgrounds rather than content images. Small SVG icons embedded as CSS backgrounds using this approach eliminate HTTP requests for each icon file, which matters for performance on icon-heavy interfaces.
HTML img tag wraps the Data URI in a complete <img> element with the Base64 string as the src attribute value:
<img src=""data:image/png;base64,..."" alt=""description"">
This is the format you want for self-contained HTML files, email templates, or any situation where the HTML needs to render the image without any dependency on external files.
For decoding Base64 back to an image, paste the Base64 string into the input area. The tool validates the input, decodes it, shows a preview of the resulting image, and lets you download the decoded image file.
Built-in validation flags malformed Base64 input before you try to use it in a context where an invalid string would fail silently or produce a broken image.
Self-contained email templates. Email clients are inconsistent about loading externally referenced images. Many block external images by default, requiring the recipient to click a ""load images"" prompt before seeing anything. Embedding images as Base64 in the email HTML ensures images render without external requests. This is most appropriate for small images like logos, icons, and decorative elements rather than large photographs, since email file size limits apply.
Inline SVG icons in stylesheets. SVG icons are commonly used in web interfaces, and every external icon file is an HTTP request. For small sets of frequently used icons, embedding them as Base64-encoded SVG in a stylesheet or using them as Data URIs in CSS eliminates those requests. The CSS Gradient Generator and CSS-based approaches to backgrounds and decorative elements follow the same philosophy of reducing external asset dependencies.
Single-file HTML documents. Fully portable HTML files that work without a server and without any accompanying asset directory are useful for documentation, prototypes, offline tools, and shared deliverables that need to work anywhere. Embedding images as Base64 makes these files genuinely self-contained.
API payloads and data structures. Some APIs accept images as Base64 strings in JSON request bodies rather than as multipart file uploads. Image recognition APIs, document processing services, and various AI APIs commonly use this format. This tool converts your image to the plain Base64 format those APIs expect.
Canvas and WebGL applications. JavaScript applications that manipulate images programmatically sometimes require Base64 input for loading images into canvas contexts or passing them to processing libraries, particularly when cross-origin resource sharing restrictions would block loading external image URLs.
Base64 encoding increases file size by approximately 33%. A 100 KB image becomes roughly 133 KB when encoded. For small images, this overhead is negligible relative to the benefit of eliminating an HTTP request. For large images, the math works against you. A 500 KB photograph encoded as Base64 adds 167 KB to the HTML or CSS file that embeds it, and that file itself must be downloaded before the browser can render anything on the page. Large images are almost always better served as external files with proper caching headers.
The practical guideline used by most performance-focused developers is to embed images as Base64 only when they are small enough that the encoding overhead is smaller than the cost of the HTTP request itself. For HTTPS connections on modern HTTP/2 servers, that threshold is roughly 1 to 2 KB. Icons, small decorative elements, and loading spinners are good candidates. Hero images, product photographs, and content illustrations are not.
For resizing images before converting them to reduce their encoded size, the Image Resizer handles dimension and format adjustments with the same client-side processing approach. Getting images to the smallest appropriate size before encoding keeps the Base64 output manageable.
The reverse operation, converting a Base64 string back to an image file, is useful for debugging, extracting embedded images from source code or data exports, or verifying that a Base64 string contains a valid image before using it in production.
Paste any valid Base64 string, with or without the Data URI prefix, into the input area. The tool decodes it, renders a preview, and lets you download the resulting image file. Built-in validation flags input that is not valid Base64 or does not decode to a recognized image format before you spend time troubleshooting why it is not rendering somewhere else.
A Data URI is a URI scheme that embeds data inline rather than referencing an external resource. It includes the MIME type and Base64-encoded data in a single string formatted as data:[media type];base64,[data]. Browsers interpret Data URIs as if they were regular URLs, loading the embedded data instead of making an HTTP request.
No. Base64 is an encoding scheme, not an encryption method. It transforms binary data into a text-safe format but does not hide or secure the data in any way. Anyone with the Base64 string can decode it back to the original image instantly. Do not use Base64 encoding as a security measure.
The most common cause is a missing or incorrect MIME type prefix. Many contexts require the full Data URI format including the data:image/jpeg;base64, prefix. Using plain Base64 without the prefix in a context that expects a full Data URI will produce a broken image. The tool generates each format separately to make the correct choice clear.
Yes. Use the CSS background output format from this tool, which generates a complete background-image: url(""data:..."") declaration ready to paste into a stylesheet. Base64-encoded images work as values for any CSS property that accepts a URL, including background-image, border-image, list-style-image, and content in pseudo-elements.
The tool supports JPEG, PNG, GIF, WebP, SVG, and other common image formats as input. The output is the Base64 encoding of the source file's binary data regardless of format, and the MIME type in the Data URI reflects the original format.