The smallest PNG there is, as a data URL
A good way to understand data URLs is to take a tiny image and follow it all the way into a page. Our example is a PNG one pixel wide and one pixel high. It is a complete, valid image file, and it is 70 bytes long. That is small enough to read every part of it, and it is also exactly the kind of image that is worth inlining.
First, what kind of file is it? The name could say anything, so the tool looks at the first bytes instead. Every PNG in the world begins with the same eight: 89 50 4E 47 0D 0A 1A 0A in hex. The middle three spell PNG in ASCII. The rest were chosen to catch files damaged in transfer: a line ending that some systems rewrite, and a byte that stops old terminals from printing the file. If those eight bytes are there, the type is image/png, whatever the file is called. JPEG, GIF, WebP, AVIF, ICO and BMP each have a signature like this, and SVG is recognised by its opening svg tag.
Next, the encoding. Base64 takes the bytes three at a time, 24 bits, and splits them into four groups of 6 bits. Each 6-bit group is a number from 0 to 63, and each number is a character from A to Z, a to z, 0 to 9, + or /. Seventy bytes are 23 full groups of three with one byte left over. The 23 groups make 92 characters, and the last byte is padded out to make 4 more, two of them = signs. So the 70-byte file becomes 96 characters of Base64. Put "data:image/png;base64," in front, 22 characters, and the whole data URL is 118 characters long.
That ratio is the cost of the method. 96 characters for 70 bytes is 4 for every 3, about 37% more here because of the padding on such a small file, and closer to exactly 33% on larger ones. For this pixel it does not matter: 118 characters inside a stylesheet is far cheaper than a separate HTTP request, which carries hundreds of bytes of headers and a round trip to the server. That is the case data URLs were made for.
Scale it up and the trade turns around. A 200 KB photo becomes about 267 KB of text, inside your HTML or CSS. It cannot be cached separately, so it is downloaded again every time that file is. It cannot start loading until the file around it has been read. And it makes the file harder to read and review. The page warns you when the result is large for this reason. A rough rule: inline what is a few kilobytes or less and needed for the first paint, and serve everything else as a normal file.
Two more limits. SVG is already text, so Base64 makes it bigger for no reason; a URL-encoded SVG data URL is usually shorter. And many email clients strip data URLs, so they are a poor fit for HTML email. All of the reading and encoding here happens in your browser. The image never leaves your device.