Skip to content
ToolPlankDEV
Image & SVG Tools
100% In-Browser Execution

Updated:

Base64 PNG and Image to Base64 Converter

Turn a PNG, JPG, GIF, WebP, SVG or other image into a base64 png string or a ready-to-paste data URI. Choose plain Base64, CSS, HTML or Markdown, see the size cost, then copy. Your files are never uploaded.

Processing in browser...

Loading the tool. It runs entirely in your browser, so your data is never uploaded.

More free tools you may need next.

Quick Guide

How to use Image to Base64

Simple step-by-step instructions to get the exact output you need.

  1. 01

    Add your images

    Drop image files onto the box or press Select images. PNG, JPG, GIF, WebP, AVIF, BMP, ICO and SVG work, up to 5 MB each and 20 at a time. Press Sample if you only want to see what the output looks like.

  2. 02

    Choose the output format

    Data URI is the full string that starts with data:image/png;base64, and works as an image address. CSS, HTML img and Markdown wrap that string in a ready-to-paste snippet. Base64 only gives the bare text, and you can break it into lines of 64 or 76 characters.

  3. 03

    Check the size

    Each image shows a preview, the file size and how many characters the encoded text has. If the string is long, a warning tells you that inlining may not be a good idea.

  4. 04

    Copy or download the text

    Press Copy to put the whole output on your clipboard, or Download .txt to save it as a file. The box shows only the first 20,000 characters of very long strings, but Copy and Download always include all of it.

What a Base64 PNG Is

A PNG file is a stream of bytes. Base64 is a way to write any bytes using only 64 safe text characters: letters, digits, plus and slash. A base64 png is simply the bytes of a PNG file written in that alphabet, so the image can live inside a text file, a style sheet, a JSON value or an email.

The tool reads the file in your browser, encodes the bytes and builds the text. It works the same way for JPG, GIF, WebP, AVIF, BMP, ICO and SVG files. To encode ordinary text instead of a file, use Base64 Encode.

Convert an Image to Base64: A Worked Example

Here is a tiny PNG of 70 bytes after conversion. The bare Base64 text is 96 characters:

Text
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGNg+M/A8B8ABQACAam5sAAAAABJRU5ErkJggg==

Every PNG starts with the same eight bytes, so every base64 png starts with iVBORw0KGgo. JPEG files usually start with /9j/, GIF files with R0lGOD and WebP files with UklGR. If your string starts with something else, it is not one of those formats.

The same text as a data URI, which is what you paste into an image source:

Text
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGNg+M/A8B8ABQACAam5sAAAAABJRU5ErkJggg==

Data URI, CSS, HTML and Markdown Output

The format menu changes only how the same Base64 text is wrapped. For the example above, with the file name tiny-dot.png:

  • Data URI: data:image/png;base64,.... Use it anywhere a browser expects an image address.
  • CSS: background-image: url("data:image/png;base64,...");. Paste it into a rule.
  • HTML img: <img src="data:image/png;base64,..." alt="tiny dot">. The alt text is made from the file name, so check it and write a proper description if the image matters to readers.
  • Markdown: ![tiny dot](data:image/png;base64,...). Not every Markdown renderer allows data URIs, so test it where you will use it.
  • Base64 only: the bare text with no prefix, for APIs and JSON fields that ask for a Base64 string and give the type separately.

The line length setting applies to Base64 only. Some older tools and email formats expect lines of 76 characters, and PEM-style text uses 64. A data URI is never split, because a line break inside it would break the address.

How Much Bigger Does Base64 Make an Image?

Base64 writes every 3 bytes as 4 characters, so the text is about one third larger than the file. A file of 10,000 bytes becomes 13,336 characters. Very small files are a little worse because of padding: the 70-byte example above becomes 96 characters. The tool shows the exact number for each image.

A data URI also cannot be cached on its own. If the same icon is used on ten pages, the string is downloaded ten times as part of those pages, while a normal image file is downloaded once and reused. That is why the tool warns you at about 100 KB of encoded text.

When to Inline an Image and When Not To

Inlining can make sense for small, rarely changing images:

  • Tiny icons and background patterns in a single CSS file, so the page does not need an extra request.
  • HTML email, where linked images are often blocked until the reader allows them. Mail clients treat data URIs differently, so test with the clients you care about.
  • Single-file pages, demos and bug reports where everything has to be in one document.
  • JSON or API requests that carry a small image as a text field.

For photos and large graphics, link a normal file instead. Inlined data makes the HTML or CSS bigger, delays other content and cannot be cached separately. Photos also tend to carry location and camera details, which you can check and remove first with the EXIF Remover.

SVG to Base64

An SVG is already text, so Base64 is not the only choice. You can put SVG markup directly in a page, or use a URL-encoded data URI, which is often shorter than Base64. Base64 still has one advantage: the string contains no quotes, angle brackets or spaces, so it never breaks the attribute or CSS rule it sits in.

This tool detects SVG from the file contents and uses the type image/svg+xml. If you need a PNG instead, convert it first with SVG to PNG.

Limits and Things to Know

  • Each file can be up to 5 MB and you can add 20 at a time. A 5 MB image becomes about 7 million characters, which is more than most editors handle comfortably.
  • The tool does not resize, compress or change the image. The bytes in the output are the bytes of your file.
  • The type in the data URI is found by looking at the start of the file, not the file name. A file called photo.png that is really a JPEG is labeled as JPEG.
  • If the start of a file is not a known image format, the tool falls back to the type your browser reports, and refuses files that are not images.
  • To turn Base64 text back into a picture, use Base64 to Image. For plain text, see Base64 Decode. For a PDF file, use PDF to Base64.

Your Images Stay in Your Browser

The file is read and encoded by code running in your browser tab. It is not sent to a server and is not stored. Closing or reloading the page removes it. See the Privacy Policy for details.

Frequently Asked Questions

Technical Q&A for Image to Base64

Common questions about edge cases, character encoding, and privacy guarantees.

Drop the image onto the tool or press Select images. The Base64 text appears under the preview. Press Copy to use it.

Add your PNG file and choose Base64 only to get the bare string, or Data URI to get a string that starts with data:image/png;base64,. Both contain the same bytes.

Choose HTML img as the output format. The tool gives you a complete img tag with the data URI as its source, which you can paste into your page.

Add the SVG file. The tool detects it and creates a data URI with the type image/svg+xml. The same works for CSS, HTML and Markdown output.

Yes. JPG and JPEG files work the same way as PNG. The data URI uses image/jpeg and the Base64 text usually starts with /9j/.

It is an image file written as text. The bytes of the file are converted to letters, digits, plus and slash, so the image can sit inside HTML, CSS, JSON or an email.

Leave the output format on Data URI. The result is the image type, the word base64 and the encoded text in one string that works as an image address.

Base64 writes every 3 bytes as 4 characters, so the text is about one third larger than the file. Very small files grow a little more because of padding.

Usually not. Large strings make the page or stylesheet heavier and the image cannot be cached separately. Small icons are the best fit.

No. The file is read and encoded in your browser and is not sent to a server or saved. Reloading the page removes it.