piapia123
en

Convert Any File to Base64

Encoding

Everything runs locally in your browser — nothing is uploaded

Drop a file here, or click to choose

One file · processed entirely on your device

The file is read inside your browser only — nothing is uploaded. It keeps working offline.

Turn a file into Base64 text — drop it in and nothing gets uploaded. The data URL it produces (`data:image/png;base64,…`) pastes straight into `<img src>`, a CSS `url()` or a JSON field, saving a request; that is how small but critical assets (icons, small fonts, loading placeholders) are usually shipped. ⚠️ Do not make a habit of it, though. Base64 inflates the size by about a third, and because it travels inside HTML/CSS the browser loses independent caching and parallel fetching for that asset — beyond a few kilobytes the page gets slower, not faster. The test is simple: ask whether the file is bigger than a few KB before inlining it. The limit here is 4 MB, and the reason is not compute but the page: a 4 MB file becomes a 5.5 MB string, and rendering that much text in the DOM visibly stalls the browser. The hash tool handles 512 MB because its output is always the same length — how much is read has nothing to do with how much comes out. For anything larger, `base64 -w0 input > output.txt` on the command line.

Features

  • Any file type, drag and drop, producing Base64 and the full data URL
  • The headline is the data URL with a copy button — ready for src, url() or JSON
  • Lists the file name, original size, encoded size, MIME and actual length
  • Treats an empty MIME as application/octet-stream instead of guessing
  • States the cost of Base64 (a third larger, no independent caching) rather than just the result
  • Nothing is uploaded; works offline

How to use

  1. Drag your file onto the dashed area
  2. The data URL appears at the top — copy it with the button on the right
  3. The table below shows sizes, MIME and the encoded length
  4. Paste it into src, url() or a data field

FAQ

What is the difference between Base64 and a data URL?
Base64 is the encoded text itself; a data URL is the complete address that carries the type: `data:image/png;base64,` followed by that text. Pasting into `src` or `url()` needs the latter — given bare Base64 the browser does not know what it is. This tool gives you both, with the usable data URL as the headline.
Why is inlining everything as Base64 a bad idea?
Three costs. Size: Base64 is about a third larger (three bytes become four characters). Caching: an inlined asset travels with the HTML/CSS, so any change means re-downloading the whole block, whereas a separate file caches on its own. Parallelism: the browser can no longer fetch that asset in parallel. The rule of thumb is a few KB, and only for things that will actually be used — small icons, a 1×1 placeholder, a hundred bytes of font. Reference large files normally.
How large a font can I inline in CSS?
Fonts are the best candidates for inlining: they block text rendering, so every extra request is a longer blank period (FOIT). But a CJK font can run to several megabytes — that is a case for inlining a subset (only the glyphs actually used), not the whole file. Latin fonts are usually 10–30 KB, and inlining those is routine. For CJK, subsetting matters far more than inlining.
Why the 4 MB limit?
Because the Base64 output is text that has to go into the DOM to be displayed and copied. A 4 MB file becomes a 5.5 MB string, and rendering that much text already strains the browser. The hash tool takes 512 MB because its output is always a fixed-length digest — reading more bytes does not produce more text. For larger files use `base64 -w0 input > output.txt`.

Related tools