File to Base64 Converter
Encode any file — image, PDF, video, font, archive — as Base64, a data URI, hex or a byte array.
This encodes any file — image, PDF, video, font, archive or arbitrary binary — into Base64, a data URI, hexadecimal, or a ready-to-paste array for JavaScript, C or Python. The MIME type is detected from the file's magic bytes rather than its extension, and everything is encoded in your browser.
Runs in your browser- File types
- Any — 24 formats are identified by magic bytes, the rest encode as raw binary
- Output formats
- 10 — data URI, Base64, Base64url, CSS, HTML, hex, JavaScript, C, Python and JSON
- Overhead
- Base64 increases size by approximately 33%
- Privacy
- Runs entirely in your browser — nothing is uploaded
- Cost
- Free, unlimited, no sign-up
Frequently asked questions
Why is the Base64 bigger than my file?
When should I inline an image as a data URI?
How is the MIME type detected?
How to use the file to base64 converter
- 1Select your files — the file stays on your device and is never uploaded.
- 2Choose the output as.
- 3Enter or paste your mime type override.
- 4Set the wrap lines at.
- 5Turn "Include a size warning" on or off as needed.
- 6Press Run, then download the result when it is ready.
Embed this tool
Put the working file to base64 converter on your own site. It runs in your visitors' browsers exactly as it does here — free, no account, nothing uploaded.
Share this tool
Related tools
PDF to Base64 ConverterEncode a PDF as a Base64 string or a data URI, ready to embed in code.Base64 to File ConverterDecode Base64, a data URI or hex back into a downloadable file, with the type detected automatically.Multi-Format EncoderEncode text into Base64, hex, binary, URL, HTML entities, ROT13 and more, all at once.Base64 Encoder & DecoderEncode and decode Base64 with automatic direction detection, plus file and data-URI support.Base64 to PDF ConverterDecode a Base64 string into a real, downloadable PDF file.Data URI GeneratorTurn text, SVG or CSS into a data: URI you can inline directly in HTML or stylesheets.
Last updated
More encoders & decoders