A data URI puts a whole file inside a URL: data:, the media type, ;base64, and the bytes as Base64 text (RFC 2397). The media type is the part converters most often get wrong, because they take it from the file name. Here it is read from the bytes, using the signatures in the WHATWG MIME Sniffing standard — 89 50 4E 47 0D 0A 1A 0A for PNG, FF D8 FF for JPEG — so a JPEG renamed to .png still gets image/jpeg, and the mismatch is pointed out. Width and height come from the header (PNG’s IHDR chunk, JPEG’s frame header, WebP’s VP8, VP8L or VP8X chunk) without decoding a pixel; AVIF and HEIC keep theirs several boxes deep, so they are left blank rather than guessed. The file is read by the browser and never uploaded, which matters when a screenshot shows a customer’s details.
Inlining is a trade, and above a few kilobytes usually a poor one. Base64 writes every three bytes as four characters, so the text is a third larger than the file before the prefix is added. More importantly, an inlined image cannot be cached on its own: it is downloaded again every time the page or stylesheet that holds it changes, and inside a stylesheet it delays rendering until the whole file has arrived. Build tools draw the same line — Vite inlines assets only below 4 KiB by default — and this tool warns above it. Small icons and placeholders are where a data URI earns its keep.
SVG is already text, so it does not need Base64. Percent-encoding only what would break it — %, #, double quotes, &, angle brackets, backslashes, control characters and non-ASCII — is usually shorter, and both forms are offered with their lengths. Two mistakes cause most blank SVGs: a raw # in a colour such as fill="#fff", which a URL reads as the start of its fragment, cutting off the rest; and a missing xmlns="http://www.w3.org/2000/svg", which inline SVG can do without but an SVG loaded as an image cannot. Decoding accepts a data URI or bare Base64 with line breaks, the URL-safe alphabet or no padding, and when the bytes are not an image it says what they are: a PDF, a ZIP, plain text, Base64 encoded twice. The preview is built only from bytes recognised as an image, inside an img element, where an SVG’s scripts cannot run.