# 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.

**URL:** https://convertto.tech/t/file-to-base64
**Category:** Encoders & Decoders (https://convertto.tech/c/encoding-tools)
**Privacy:** Runs entirely in the browser; no upload
**Cost:** Free, no sign-up
**Last updated:** 2026-08-01

## Key facts

- **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

## How to use

1. Select your files — the file stays on your device and is never uploaded.
2. Choose the output as.
3. Enter or paste your mime type override.
4. Set the wrap lines at.
5. Turn "Include a size warning" on or off as needed.
6. Press Run, then download the result when it is ready.

## FAQ

### Why is the Base64 bigger than my file?

Base64 represents every 3 bytes as 4 printable characters, so the output is always about 33% larger. That is the price of making binary data safe to put in text-only places such as JSON, HTML and email.

### When should I inline an image as a data URI?

For small assets — icons under a few kilobytes, or a font subset — where removing a request matters more than the size increase. For anything larger, a separate file wins because it can be cached, compressed and loaded in parallel.

### How is the MIME type detected?

From the file's leading bytes, not its extension. A PNG always starts with the same eight-byte signature, so the type is read from the content itself — which is why renaming a file does not fool it.

## Related tools

- [PDF to Base64 Converter](https://convertto.tech/t/pdf-to-base64): Encode a PDF as a Base64 string or a data URI, ready to embed in code.
- [Base64 to File Converter](https://convertto.tech/t/base64-to-file): Decode Base64, a data URI or hex back into a downloadable file, with the type detected automatically.
- [Multi-Format Encoder](https://convertto.tech/t/multi-encoder): Encode text into Base64, hex, binary, URL, HTML entities, ROT13 and more, all at once.
- [Base64 Encoder & Decoder](https://convertto.tech/t/base64-encode-decode): Encode and decode Base64 with automatic direction detection, plus file and data-URI support.
- [Base64 to PDF Converter](https://convertto.tech/t/base64-to-pdf): Decode a Base64 string into a real, downloadable PDF file.
- [Data URI Generator](https://convertto.tech/t/data-uri-generator): Turn text, SVG or CSS into a data: URI you can inline directly in HTML or stylesheets.
- [Binary to Text Converter](https://convertto.tech/t/binary-to-text): Translate text into binary ones and zeros, and decode binary back into readable text.
- [Number Base Converter](https://convertto.tech/t/number-base-converter): Convert numbers between any base from 2 to 36 — binary, octal, decimal, hexadecimal and beyond.
