Scenario
A single-file HTML demo needs a small logo, and shipping a second file alongside it defeats the point of "single-file." The standard trick is a data URI: the image bytes Base64-encoded and inlined as data:image/png;base64,... directly in the src or CSS url(). It works beautifully for icons and breaks budgets quickly for anything bigger — Base64 inflates size by roughly a third, and inlined bytes cannot be cached separately.
Broken input
small logo image for an inline demo
Goal
Use Image to Base64 Converter to produce a complete, paste-ready data URI — correct MIME prefix included — and confirm the size cost is acceptable before inlining.
Tool sequence
- Open Image to Base64 Converter.
- Load the logo file; the converter detects the format and builds the
data:image/png;base64,prefix to match. - Check the output size — a few KB of image becomes ~33% more characters of Base64; if the URI runs to hundreds of KB, keep the image as a file instead.
- Copy the entire URI including the prefix; the Base64 payload alone renders nothing.
- Paste into
<img src="...">or CSSurl(...)and open the demo; if the image fails to render, the usual culprit is a truncated paste or missing prefix — decode a snippet with Base64 Encoder to check integrity.
Checkpoint output
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...
└──────┬──────┘└──┬──┘└────────────┬────────────┘
MIME marker Base64 payload
A complete data URI with format prefix and payload — the demo renders the logo with zero extra network requests.
Common mistakes
- Inlining large images that should stay separate files — the page loses caching and the HTML becomes megabytes.
- Copying only the Base64 payload without the
data:image/...;base64,prefix and getting a broken image icon. - Forgetting that data URIs turn image updates into massive text diffs in code review.
- Inlining the same image in five places, paying its full size five times where one cached file would be fetched once.
Related tools and lessons
- Base64 Encoder - Encode or decode Base64 strings.
- Binary Code Translator - Convert text to binary and back.
- URL Encoder - Encode or decode URL strings.
- Related lesson: Tell Encoding, Escaping, Hashing, and Encryption Apart
- Related lesson: Translate Binary Text Into Readable Characters