About this tool
Convert local files into Base64 strings and data URLs without uploading them.
File to Base64 converts any local file into a Base64 string or a complete data: URL, using the RFC 4648 alphabet where every 3 bytes become 4 characters. It is for developers embedding small assets — icons, fonts, test fixtures — directly into HTML, CSS, JSON or an API payload without a separate file request. The file is read in your browser with the File API, so nothing is uploaded, and the tool also reports the exact size increase (a constant 4/3, about 33.3%) before you commit to inlining.
Open File to Base64 on AltFTool — it loads instantly in your browser.
Drag a file into the drop zone or pick one under "Choose a file to encode" — up to 32 MB, read in this tab with the browser File API.
Toggle "Include the data: URL prefix", "URL-safe alphabet (- and _)", "Keep = padding" and "Wrap at 76 characters" to shape the encoding.
Switch the Output tab between Data URL, HTML, CSS, Markdown and JSON, then press Copy output — it always copies the whole string, not just the 4,000-character preview.
Shows encoded length as 4 x ceil(bytes / 3) and the resulting percentage overhead.
Emits the data URL plus HTML, CSS, Markdown and JSON snippets around it.
Switch between the standard alphabet and the - / _ variant, with or without = padding.
Exactly 4 characters for every 3 bytes, so about 33.3% larger — a 1,024-byte file becomes 1,368 Base64 characters. Add roughly 20-30 more characters for the data: URL prefix, and more again if you wrap lines at 76 characters.
A data URL is data:<mime>;base64,<payload> (RFC 2397) and embeds the file directly in your markup. Use it for assets under about 10 KB — icons, small fonts, one-pixel images — where saving a round trip beats the 33% size penalty and the loss of separate caching.
No. The file is read into memory in your browser tab with the File API and encoded in JavaScript there. No network request is made, which is why the tool also works offline once the page has loaded.
It is the RFC 4648 §5 variant that replaces + with - and / with _, so the string can sit inside a URL, a filename or a JWT without escaping. Padding = characters are usually dropped too; this tool lets you toggle both.
Add the File to Base64 widget to your blog or website — free, responsive, no signup. Just keep the “Widget by AltFTool” credit link visible.
<iframe src="https://www.altftool.com/embed/widget/file-to-base64"
title="File to Base64 — free AltFTool widget"
width="100%" height="640" style="border:0;border-radius:12px;overflow:hidden"
loading="lazy" referrerpolicy="no-referrer-when-downgrade" allow="clipboard-write"></iframe>
<p style="font-size:12px;margin:4px 0 0">Widget by <a href="https://www.altftool.com/tools/all/file-to-base64?utm_source=embed&utm_medium=widget" rel="nofollow">AltFTool — free online tools</a></p>