How to use
- Drop a file onto the box at the top, or click it to browse. Any type is accepted, up to 10 MB.
- Check the three stats that appear — original size, Base64 size, and the exact overhead for this file.
- Copy the Raw Base64 pane when you want a plain string, or the Data URI pane for a
data:value you can drop straight into an<img src>or a CSSurl(). Download .txt saves the raw string to a file instead. - Going the other way? Paste a data URI or bare Base64 into the decode pane, optionally set a filename, and press Decode & download to get the original bytes back.
How it works
Base64 exists because plenty of channels — a JSON field, an email header, a URL, a source file — only carry text safely, yet the thing you want to move is raw bytes. The encoding maps those bytes onto 64 printable characters (A–Z, a–z, 0–9, + and /) by regrouping bits: three input bytes are 24 bits, which slice cleanly into four 6-bit groups, and each 6-bit value picks one character from that 64-symbol alphabet.
Take the three ASCII bytes of the word Fox. F, o and x are 0x46, 0x6F and 0x78, or 01000110 01101111 01111000 in binary. Regrouped into six-bit chunks that becomes 010001 100110 111101 111000 — the values 17, 38, 61 and 56. Looking those up in the alphabet gives R, m, 9 and 4, so Fox encodes to Rm94. This tool then wraps the string with the MIME type your browser reports for the dropped file, producing the data URI data:text/plain;base64,Rm94. When the input length is not a multiple of three, the last group is filled out with one or two = characters so the output always divides evenly into fours — that is why encoded text often ends in padding.
Decoding runs the map backwards. The tool splits a data URI at its first comma, reads the MIME type from the header, then Base64-decodes the payload — normalising url-safe variants (- and _) and stray whitespace first — and hands the bytes back as a download.
Use cases & limitations
Reach for file-to-Base64 when an asset has to travel as text: inlining a small icon into a stylesheet, embedding a logo in a self-contained HTML report, dropping a font into a single-file demo, or pushing a binary through a JSON API that has no field for raw uploads. For plain strings rather than files, the Base64 encoder/decoder is the better fit.
The honest cost is size. Because every 3 bytes become 4 characters, the output is about 33% larger than the source, and inlined bytes cannot be cached separately from the document that holds them — past a few kilobytes, a linked file usually loads faster. That is also why encoding is capped at 10 MB here: the resulting ~13.7 MB of text is near the edge of what clipboards and editors handle. If your goal is a smaller inlined image, shrink it with the image compressor before encoding, and use the hash generator if you need to confirm a decoded file matches the original byte for byte.
Privacy note
Your file is read into memory with the browser’s FileReader API and converted on this page by script running in your tab — no request carrying the file or its Base64 result is ever sent. Encoding and decoding both keep working if you go offline after the page loads, and nothing is stored between sessions. To check this for yourself rather than take our word for it, open your browser’s network tab and watch it stay silent while you drop a file.