File to Base64 Converter
Drop any file and get a raw Base64 string — or toggle to the full data URI. Everything runs in your browser, so the file is never uploaded.
How to convert a file to Base64
Drag any file onto the drop zone above (or click to browse). The tool reads it locally with the browser's FileReader API and produces a raw Base64 string by default — just the encoded payload, with no data: prefix. Click Copy, then paste it wherever you need it. Use the Data URI toggle if you want the full data:<mime>;base64,… form for inlining in HTML or CSS.
Raw Base64 vs data URI
The two outputs serve different jobs:
- Raw Base64 — just the encoded bytes, e.g.
JVBERi0xLjcK…. This is what you want for environment variables, JSON payloads, database columns, or anywhere you store the value and attach its type separately. - Data URI — the same payload with a
data:<mime>;base64,prefix, e.g.data:application/pdf;base64,JVBERi0xLjcK…. Use this for inlining directly in HTML (<img>,<embed>) or CSSurl(), where the browser needs the MIME type.
Tip: if a value already starts with data:, it's a data URI; strip everything up to and including the comma to get the raw Base64 back.
How big does the file get?
Base64 makes data about 33% larger. The encoding turns every 3 bytes of input into 4 ASCII characters, so the output length is roughly ceil(bytes / 3) × 4. A 3 MB file becomes about 4 MB of text, plus one or two = padding characters at the end. Keep that overhead in mind when storing Base64 in databases or sending it over the wire.
Is this private?
Yes. The conversion happens entirely client-side in JavaScript. Your file is read into memory in the browser and encoded locally — it is never sent to a server. That matters for sensitive files: SSH keys, TLS certificates, signing keys, or confidential documents stay on your machine. You can confirm it by opening DevTools → Network: adding a file fires no upload request.
Frequently asked questions
How do I convert a file to Base64?
Drop it onto the converter above. It reads the file with the FileReader API and shows the raw Base64 instantly. Toggle Data URI if you also want the data: prefix.
Can I encode binary files?
Yes — any file type works. Base64 exists precisely to represent arbitrary binary data as ASCII text, so PDFs, ZIP archives, images, fonts, and executables all encode safely.
Is it safe to convert files online?
On base64.dev, yes. Everything runs in your browser and nothing is uploaded, so even private keys, certificates, and confidential documents never leave your device.
How much bigger does Base64 make a file?
About 33% larger — 4 output characters for every 3 input bytes. A 3 MB file becomes roughly 4 MB of text plus a little padding.
Need text or URL-safe Base64?
The main base64.dev tool handles text, files, and URL-safe mode with auto-detect.
Open base64.dev →