> file | base64 | data url <
// Drag and drop any file to convert it to a Base64 Data URL
Drag & drop any file here or click to browse
// PDFs, fonts, docs, images, audio, anything
Any File Type
Works with PDFs, fonts, Office documents, images, audio, video and arbitrary binaries. MIME type is detected automatically.
Drag & Drop
Drop a file from your desktop or pick one through the native file picker. Conversion uses the browser FileReader API.
Multiple Outputs
Get the full Data URL, raw Base64, an <img> tag (for images), and a ready-to-paste CSS url(...) snippet.
// ABOUT FILE TO BASE64
How It Works:
FileReader.readAsDataURL reads the binary file and emits a Data URL of the form data:<mime>;base64,<payload>. We split off the prefix to expose the raw Base64, and synthesize CSS and img-tag snippets from the same source.
Example:
data:application/pdf;base64,JVBERi0xLjQKJ…
Standards:
- >RFC 4648: The Base16, Base32, and Base64 Data Encodings
- >RFC 2397: The 'data' URL scheme
- >HTML FileReader API (W3C File API)
- >Output is ~33% larger than the source binary by design
Common Use Cases:
- >Embed assets directly into HTML, CSS or JSON
- >Avoid extra HTTP requests in single-file demos
- >Send binary payloads through text-only APIs
- >Inline custom fonts or icons in emails
- >Quickly inspect file headers via Base64
>> frequently asked questions
Q: How big can the file be?
A: There is no hard limit, but Base64 inflates payloads by roughly 33% (4 output characters per 3 input bytes) and very large strings may freeze the browser tab while the FileReader resolves and the encoded text is written to the textarea. We surface a warning above 5 MB; in practice keep inputs under 25 MB for a smooth interactive experience.
Q: Is the file uploaded anywhere?
A: No. Reading and encoding happen entirely in your browser using the FileReader API — nothing leaves your machine, and there are no analytics events tied to file content. You can disconnect from the network, encode a sensitive document, copy the Base64, and reconnect; the workflow does not touch any server at any point.
Q: What is the difference between a Data URL and raw Base64?
A: A Data URL has the form data:
Q: Does this work for non-image files?
A: Yes — any binary works. PDFs, woff2 fonts, docx archives, mp3, even arbitrary .bin blobs are all encoded the same way. The <img> tag output is automatically hidden for non-image MIME types because browsers cannot render those bytes through an <img> element, but the Data URL and raw Base64 outputs are still populated.
Q: Can I decode Base64 back into a file?
A: Yes - use the matching decoders on this site such as Base64 to PDF, Base64 to Image, or Base64 to Audio Player. Each one accepts either a raw Base64 payload or a full Data URL, validates the input, and gives you a previewable, downloadable file. The round-trip is loss-less for any binary.
Q: How is the MIME type detected?
A: The browser examines the file's extension and, for some types, peeks at the magic bytes. The detected value is what the OS reports via File.type. If the file has no recognizable extension, expect application/octet-stream — the encoding works regardless, but the Data URL prefix will be generic.