Cookies This site keeps only what it needs to work. There is no analytics and no advertising on it today, and nothing here follows you to other sites. Read the privacy policy

Choose what to allow
+92 312 8299940Free Quote
EN – Language: English
Free tool, nothing to install

Image To Base64 Converter
Data URI, HTML, CSS And Markdown

The tool called "image to base64 converter" converts a photo into a data URI (uniform resource identifier), image tag, CSS, or markdown format. This tool also allows you to convert a Base64-encoded image back into a photo. All conversion processes occur locally on your machine, within your browser. Nothing gets uploaded.

  • FreePrice
  • 8Types
  • NoneSign-up
  • NoneUploads

Image To Base64 Converter

Turn a picture into a data URI, or Base64 back into a picture

Drop an image here, or click to choose onePNG, JPG, GIF, WebP, AVIF, BMP, ICO or SVG, up to 10 MB
Preview

Your image shows here.

Type
—
Pixels
—
Original size
—
Base64 size
—
Extra
—

Ready. Choose an image or drop one here.

Your browser does all of the work here, in this tab. We upload nothing, store nothing and log nothing.
Add a link to this tool on your own site

Copy the code below and drop it into your page. It places a link to this free tool.

Guides for this tool

Articles with worked examples, tables and a short video that help you get more from this tool.

The short version

What An Image To Base64 Converter Does For You

A typical web page will load each image as a separate file. Sometimes though, you want an image to be part of the actual web page and so you will need to have that image represented as text.

The job of an image to Base64 converter. Choose the image you would like to convert. Pick the output format you like best. You will instantly see the converted text and can then download/save/copy it in one step.

It can also work the other way around. If you paste a data URI or a simple base64 encoded string, the image will appear. You can see the actual content of that long string, and you can download the image.

No work will be done on our servers, everything will take place within your web browser. So, any images that are loaded into the system will remain on your personal computer/device. This is especially important for logos, screenshots and private photos.

What Exactly Is A Data URI, And Why Use One

A data URI packs a file inside a web address. It starts with the word data, then the file type, then the word base64, then the encoded bytes. A PNG, for example, starts with data:image/png;base64, and then a long run of letters.

Drawing of a picture file on the left and an arrow to a long Base64 text on the right
A picture becomes text.

This saves the browser a second request. It will read the picture directly from the text.

For more detail, see: RFC 2397, the data URL scheme.

How Base64 Works

Base64 rewrites every three bytes as four letters, digits or symbols. So the text grows by about one third. For example, a 30 KB picture becomes about 40 KB of text.

Also, the tool displays the extra size of the image, allowing you to estimate the cost before copying/pasting the image.

Turning Any Image Into A Line Of Base64 Text

First, drag and drop an image onto the box, or select a file by clicking on the box. Then choose a format. When you use Data URI, you’ll get the entire string. When you use Plain Base64, you’ll only get the encoded section of the string.

Image to base64 converter showing a sample picture, its data URI and the size numbers
A sample picture as a data URI.

Your image shows up in the preview panel right away. Then the numbers show its type, its size in pixels, its file size and its Base64 size.

Dropping A Data URI Straight Into HTML

Create an HTML image tag using the tool given, then copy and paste the generated code into your website. The tool will generate the HTML image tag with the data URI, the alt text derived from the file name, as well as the width and height of the image.

Dropping A Data URI Straight Into CSS

You’re going to select a CSS background image. Your tool will write out the CSS for the background-image property. That way, you’ll have a small image (icon) in your style sheet. When the style sheet is loaded, so is that small image, without any other requests.

Dropping A Data URI Straight Into Markdown

Select a markdown image. The tool creates an image tag for you in markdown syntax. Some editors and note-taking applications will display the image directly from the markdown code, rather than requiring you to save it as a separate file first.

Turn A Block Of Base64 Back Into A Picture

Reverse the direction from Base64 to image. Paste either a data URI or a plain Base64 string into the input box. The tool will check the input for validity, read the initial few bytes to work out what type of file it is, and then display the image.

After clicking on Download Image to download the image, the tool will read the bytes of the downloaded image and name the file with the correct file extension based upon those bytes (i.e. png, jpg, etc.).

Supported Image Types

It accepts PNG, JPG, GIF, WebP, AVIF, BMP, ICO and SVG files. Also, it finds the type from the file itself, not from the name. So a wrong ending does not fool it.

When A Base64 Image Is The Right Choice

First, they reduce the number of requests by one per picture. But they increase the amount of text and do not use the browser’s cache for the pictures.

That is why they are best kept for small images.

When To Skip Base64 Images

A big picture as Base64 makes a page heavy. In that case the browser cannot cache it separately from the page. Also, it is harder to update later. So keep photos as normal files, and keep data URIs below about 100 KB.

Break Base64 Into Lines

For systems like email that use 76-character lines, check the "line breaks" box and the tool will automatically format your Base64 into those constraints.

Check Private Images Safely

You don’t have to worry about converting your private images (such as ID cards and screenshots) because they stay on your computer.

Safe By Design

All steps will occur in your browser. No data entered on this page will ever leave, and no data will remain after the browser has been closed. This means that your image is yours alone.

Video guide

How the Image to Base64 Converter Works, Step by Step

This brief video shows each step from start to finish. Choose your language below, and switch on captions if they help.

How it works

Image To Base64 In A Few Quick Steps

Four steps take you from a picture to text.

  • Pick a direction

    Select either Image to Base64 or Base64 to image.

  • Add your picture

    Drop a file on the box, or paste your Base64 text.

  • Choose the format

    Pick a data URI, plain Base64, an img tag, CSS or Markdown.

  • Copy or download

    Copy the text, save it as a file, or download the picture.

Why this one

How This Converter Stands Out

It goes both ways, it shows the cost, and it keeps your picture private.

  • Both directions

    Turn a picture into Base64, and Base64 back into a picture.

  • Five formats

    Data URI, plain Base64, img tag, CSS and Markdown.

  • Eight image types

    It accepts PNG, JPG, GIF, WebP, AVIF, BMP, ICO and SVG files.

  • Shows the size cost

    See the file size, the Base64 size and the extra.

  • Live preview

    See the picture before you copy anything.

  • Nothing leaves your tab

    Your own browser opens the image file itself. We never see it.

Good habits

Habits For Using Base64 Images Well

A few habits keep your pages fast.

  • Keep images small. Stay below about 100 KB for each data URI.
  • Compress first. Shrink the picture before you encode it, since Base64 adds a third.
  • Use it for icons. Tiny icons and logos suit data URIs best.
  • Keep photos as files. Big photos load better as normal files that the browser can cache.
  • Prefer SVG for simple art. SVG stays small, and it scales to any size.
  • Write an alt text. Check the alt text in the img tag, and make it describe the picture.
  • Enter the picture’s width and height in pixels. The tool adds them so nothing jumps around while the page loads.
  • Never treat Base64 as a secret. Anybody can decode it, so it conceals nothing.
  • Test in the page. Paste the result into your page and check that it shows.
  • Keep the original. Save the source picture, so you can change it later.
  • Mind private pictures. Do not paste a private picture into a public page.
Worth avoiding

Common Base64 Image Mistakes This Tool Helps You Avoid

Each of these quietly slows a page down.

  • Encoding big photos

    A large photo makes the page heavy and slow.

  • Forgetting the extra third

    Base64 text ends up about 33% bigger than the original file.

  • A wrong file type

    The type in the data URI must match the picture.

  • Broken lines

    A data URI must stay on one line inside HTML and CSS.

  • Missing alt text

    A picture without alt text hurts accessibility.

  • Trusting it as a lock

    Base64 only changes the shape of the data. Base64 gives your image no protection whatsoever.

Questions

Image To Base64 Questions We Hear Most Often

Does this image to Base64 converter cost anything?

Yes. It is free of cost, does not need an account, and is without any restrictions. Your browser is what performs most of the work, so, there will be no cost to you for recovering the expense of our servers.

Is the image I load kept on my device?

No. This website doesn’t download the image file, but your web browser will open it. Nothing is sent to our website and we don’t save anything.

What is Base64?

It is used for writing bytes using only 64 safe characters (letters, digits, +, /). This allows an image to be sent through email as text.

What does a finished data URI look like?

It’s a web address that carries the file inside it. It begins with data:image/png;base64, and the encoded text follows.

How can I turn an image into Base64?

You can either drop the image onto the box, or click the box to select a file. The result shows up right here, right away. Press Copy Result.

How do I change Base64 text back into a picture?

Paste your text into the box after changing the operation from Base64 to Image. Once you have made the change, the image will appear and be available for download.

Which image types work?

It accepts PNG, JPG, GIF, WebP, AVIF, BMP, ICO and SVG files. The tool finds the type from the bytes, not from the file name.

What is the largest image it accepts?

Up to 10 MB. Larger files would make the text too long to use.

Why is the Base64 text bigger than the file?

Base64 needs four characters for each three bytes. That makes the text roughly a third bigger than the file.

How does a data URI differ from plain Base64?

A data URI has the "type" and "base64" added to the beginning. The plain base64 is only the encoded portion, without any prefix.

How do I use a data URI in an img tag?

Select a single image from an HTML img tag. This application will generate the complete image tag for you to copy and paste onto your site.

How can I use a data URI in CSS?

The user selects a CSS background image. The system produces a background-image rule which the user may copy and paste into their style sheet.

Can I use it in Markdown?

Yes. Pick a Markdown picture. There are some editing tools that will display the image directly from the data URI.

Can it turn SVG files into Base64 as well?

The software will open an SVG file, display it, and create a data URI based on that file. Because the software views the SVG as an image, there are no scripts that can be executed within the SVG.

Can it convert several images in one go?

One at a time. Press Clear, then choose the next image.

Why can the browser not draw my image?

The file might be corrupt, or the type isn’t compatible with your browser. You should use a PNG or a JPEG.

What is the line break option for?

It takes plain Base64 and breaks it down into groups of 76 characters per group, which is what emails and other older systems use.

Is Base64 a good idea for large photos?

No. Big photos make a page heavy and the browser cannot cache them apart. Keep photos as files.

Does Base64 hide or protect an image?

No. Anybody can decript it within seconds. All it does is change the way the image is created.

Does the tool change or compress my picture?

No. The bytes of the image will remain exactly as they were. This program simply formats those bytes into a different format.

Can I save the converted result as a file?

Yes. Click Download Text File to download the text. Click Download Image to download a decoded version of the image.

Does it run on phones too, or only on desktops?

The panels can be stacked, and you may select a photo from your gallery. This will allow you to convert images at any location.

More free tools

Handy Companions For Image Work

Converting is one step. These three tools help with the rest.

Want To Turning Any Image Into A Line Of Base64 Text Now?

Just drop an image, select the format you want, and copy the text. This converter is completely free, does not need you to create an account, and will preserve all of the images you use.

Prefer Denwix on GoogleReview Denwix on Google