Black Friday: 50% off every paid plan with code BF50. Ends 5 December.

See prices

Free tool

Image to Base64, ready to paste.

Drop one or more pictures to turn each into Base64: a data URL, plain Base64, a CSS background line, an HTML img tag with the width and height, a Markdown image or a JSON field. You see each file's size before and after, since Base64 is about a third bigger, and copy one or all of them with one click. Too long? Make the picture smaller first, or write an SVG as plain text. PNG, JPG, WebP, GIF, SVG and ICO all work, with no size limit. Nothing is uploaded.

Need a custom tool, app or website? Contact us 

Converted in your browser. Your pictures are never uploaded.

Pictures as text

Embed without a separate file.

01 / Formats

Six ways to paste

Data URL, plain Base64, CSS, HTML, Markdown or JSON, switched in one menu.

02 / Size

Know the cost

Base64 text is about 33% bigger than the file. The sizes are shown side by side.

03 / Many

Several at once

Drop a batch of icons and copy each one.

Guide

How to convert an image to Base64, and when you should.

An image to Base64 converter turns a picture file into a long line of plain text, so you can paste the picture straight into HTML, CSS, Markdown or JSON instead of linking to a separate file. By default this tool reads your file exactly as it is, with no resizing or recompressing, and writes it out in the format you pick. If the text is too long, it can shrink the picture first. It shows the size of the file and the size of the text side by side, so you can see what embedding will cost.

How to use the image to Base64 converter

  1. Drop one or more pictures on the box, click to choose them, or paste one. PNG, JPG, WebP, GIF, SVG and ICO work.
  2. Under Give me, pick Data URL, Plain Base64, CSS background, HTML img tag, Markdown image or JSON field.
  3. Each picture gets its own box with a preview, its pixel size, and the size before and after.
  4. Press Copy under a picture to put its text on your clipboard, or Save as .txt for a long one. With several pictures, Copy all at the top of the side column copies them one a line, and Save all as JSON saves one file with every picture by name.
  5. To make the text shorter, use Make it smaller first: pick a Width and a File type. Every picture is redone at once.
  6. Use Add more for another batch, the × on a picture to remove it, or Clear to start over. Your settings are kept in this browser.

The five formats, and where each goes

Give meLooks likePaste it into
Data URLdata:image/png;base64,iVBORw0...Anywhere a picture address goes: an src, a url(), a JavaScript string
Plain Base64iVBORw0KGgo...JSON for an API, a database field, or code that adds its own prefix
CSS backgroundbackground-image: url("data:...");A rule in your stylesheet
HTML img tag<img src="data:..." width="64" height="64" alt="logo">An HTML page or an email template
Markdown imageMarkdown's image syntax, with the file name as alt text and the data URL in bracketsA README or notes app that shows Markdown
JSON field{"name":"logo.png","type":"image/png","width":64,...}An API request, a test fixture or a config file

The HTML tag already has the picture's real width and height, which stops the page from jumping as it loads. The alt text is the file name without its extension. Change it to a short description of the picture before you publish.

How much bigger Base64 makes a file

Base64 writes every 3 bytes of the file as 4 text characters, so the text is about a third bigger. A data URL also adds a short label at the start. Here are two examples:

  • A 6,000 byte PNG icon: 6,000 divided by 3 is 2,000 groups, times 4 is 8,000 characters. The label data:image/png;base64, adds 22 more, so 8,022 characters, about 8 KB.
  • A 300,000 byte JPG photo: 100,000 groups times 4 is 400,000 characters, plus a 23 character label. That is 400 KB of text inside your page.

The icon is a fair trade: one less file to fetch for 2 KB of extra text. The photo is not, because those 400 KB load every time the page or stylesheet loads, and the browser cannot keep the picture in its cache on its own. When a picture is over 100 KB, the tool warns you.

When to use Base64, and when not to

  • Good: small icons, logos and simple shapes in CSS; a picture in a single file HTML page or demo; a test picture inside code; a picture sent to an API that only takes JSON.
  • Not good: photos and large pictures on a website; pictures used on many pages (a normal file is cached once); anything you will want to change often, because you have to convert it again each time.

Make the text shorter

Shrink a picture before converting and the text shrinks with it. Under Make it smaller first, set a Width, such as up to 128 px for an icon, and a File type. WebP is usually the smallest, JPG suits photos with no see-through parts, and PNG keeps every pixel exact. JPG and WebP also get a Quality setting. Each picture shows its new size in brackets, and if saving again would make a file bigger, the original is kept. A moving GIF keeps only its first frame when it is saved again, so leave the settings at As it is for those. For more control, use the image compressor first.

SVG files

An SVG is already text, so it works as Base64 too. The data URL starts with data:image/svg+xml;base64,. Because the SVG is text, it can also go in a data URL without Base64: tick Write SVG as text, not Base64 and the tool writes data:image/svg+xml, followed by the SVG with only the characters that must be escaped changed, such as < to %3C. That is usually shorter than Base64 and still works in CSS and in an src. Plain Base64 is not possible in that mode, so you get the data URL. If the SVG is a simple icon, check it is not drawn with a font or linked pictures that will not travel with it.

On a Mac

You can also do it in Terminal, which is built in. Type base64 -i icon.png | pbcopy and press Return. The plain Base64 for icon.png is now on your clipboard. You still need to add the data:image/png;base64, label yourself for a data URL.

To go the other way, paste Base64 into the Base64 decoder to get the picture back. Making icons for a site? The favicon generator builds every size you need.

Questions

Good to know.

How do I convert an image to Base64?

Drop the picture and copy the result. Pick the format you need under Give me.

What is a data URL?

The whole file written as text after data:image/png;base64, so it can sit inside HTML or CSS.

Why is the Base64 bigger than the file?

Base64 uses 4 characters for every 3 bytes, about a third more.

How do I turn Base64 back into a picture?

Use the Base64 decoder.

Are my pictures uploaded?

No. They are read and converted in this browser tab, so there is no file size limit apart from your computer's memory.

How do I make the Base64 string shorter?

Use Make it smaller first: a smaller width and WebP usually cut the text the most. For an SVG, tick Write SVG as text, not Base64.

Can I convert many images at once?

Yes. Drop them all, then use Copy all, or Save all as JSON for one file with every picture by name.

How do I use a Base64 image in HTML?

Pick HTML img tag under Give me and copy it. The whole picture is inside the src, so you can paste the tag into any page without uploading a file.

Does converting to Base64 lower the image quality?

No. Base64 is a different way to write the same bytes, so the picture is identical. It only makes the data larger.

Is Base64 a way to hide or protect a picture?

No. Anyone can turn Base64 back into the picture in seconds. It is a way to store a file as text, not a lock.

What is the difference between a data URL and plain Base64?

A data URL is the Base64 with a label in front, such as data:image/png;base64,, that tells the browser what kind of file it is. Plain Base64 is just the encoded text, for code that adds the label itself or does not need one.

Listed on

Listed on JustMacAppsMotionShine on Mac App IndexMotionShine on ScrollLaunchMotionShine featured on StartupBaseFeatured on FazierFeatured on Twelve ToolsMotionShine - Featured on Smol Launch