File to Base64
Encode any file type to Base64 or a Data URI — free, instant, nothing uploaded
Upload any file
Drag & drop or click to upload
PDF, DOCX, ZIP, fonts, audio, video — any type at all
Your file never leaves this browser. There is no upload and no server.
Output
The payload only — for APIs, config files, and database columns that add their own header.
Any File. Not Just Images.
Your API wants a PDF as a string. Or the config file needs a font inlined. You search for a converter and every result only takes images. This file to Base64 encoder takes whatever you have.
Documents, archives, fonts, audio, video, certificates. Drop it in, pick raw Base64 or a Data URI, copy the result.
Nothing uploads. Once this page has loaded you can disconnect your network and it still works.
How to Convert a File to Base64 String Output
- Compress first, if the file is text. CSV, SQL dumps and logs shrink hugely when zipped.
- Drop the file in. Any type at all — there is no filter.
- Read the panel. Detected MIME type, character count, and the exact growth percentage.
- Pick your output. Raw Base64 or a complete Data URI.
- Copy it. One click.
Skip step one for anything already compressed. PDFs, JPEGs, MP4s and ZIPs have had the redundancy squeezed out already, so zipping again adds a header and saves nothing.
Where File to Base64 Encoding Actually Gets Used
Four situations account for most of the traffic to this page:
- JSON API payloads. REST endpoints that accept a document but only speak JSON.
- Config and secrets. Kubernetes secrets and CI variables that must hold a certificate on one line.
- Email attachments. MIME has encoded every attachment this way since the 1990s.
- Embedded assets. Fonts and icons inlined so a single HTML file works offline.
A caveat on the first one. Payload limits bite faster than people expect — AWS API Gateway caps request bodies at 10 MB, and Base64 adds a third before the request leaves. In our experience this is the most common reason a working upload suddenly fails in production.
Encoding an image instead? The image to Base64 converter adds CSS and HTML output formats this page does not.
Raw Base64 or a File to Data URI Conversion?
Same bytes, different wrapper. Picking wrong is the most frequent mistake we see.
| Output | Looks like | Use it for |
|---|---|---|
| Raw Base64 | JVBERi0xLjQKJc... | APIs, database columns, config files — anything that adds its own header |
| Data URI | data:application/pdf;base64,JVBERi0... | Browsers, CSS, HTML, download links |
The rule of thumb: if a browser will read it, use the Data URI. If code will read it, use raw.
Handing a Data URI to a server library is the classic bug. Most decoders expect the payload only and choke on the data: prefix, then report an unhelpful parse error.
Encoding a PDF to Base64 Without Corrupting It
PDFs are the single most common file people bring here, and they are also the easiest to break. Three things go wrong:
- Line wrapping. Command-line tools wrap at 76 characters. Strip the breaks before pasting into JSON.
- Double encoding. If the source was already Base64, encoding again produces a file that opens blank.
- Truncation. Copying from a terminal that clipped the output loses the end of the file.
A decoded PDF that opens to a blank page almost always means double encoding. The Base64 to file decoder will show you what the string really contains.
The MIME Type Gap Most Tools Ignore
Browsers do not know every extension. Drop in a .woff2, a .7z, or a .env and many report an empty type.
An empty type produces data:;base64,, which no browser will render and most parsers reject. Plenty of converters emit that and say nothing.
We fill in the correct type from the extension and tell you in the panel when we have done it. It is a small thing that saves a confusing hour.
The honest limit: we are guessing from the extension, not the contents. A file renamed to .zip will be labelled as a zip whatever is actually inside it.
Privacy and What Base64 Is Not
The file never leaves your browser. There is no upload, no queue, and no temporary storage, so it is safe for contracts, keys, and unreleased assets.
But encoding is not protection. Base64 is reversible by anyone in one click — it exists to make binary data survive text channels, nothing more.
We say this because we still see Base64 used to "hide" API keys in config files. It hides nothing. If it needs to be secret, encrypt it with our text encryption tool instead.
For plain text rather than files, the Base64 encoder and decoder handles UTF-8 correctly, including emoji.
Frequently Asked Questions
My browser reports no type for .zip or .woff files. Does that break the output?
+
Why does the base64 command in my terminal produce a different string?
+
Can I encode a whole folder?
+
Does encoding preserve file permissions or the modified date?
+
Do I need to escape the string before putting it in JSON?
+
Why does my API reject a Base64 payload that looks fine?
+
Should I Base64 a PEM certificate?
+
Why is my DOCX identified as a ZIP archive?
+
Does this work with no internet connection?
+
Should I compress the file before encoding it?
+
The Short Version
Drop the file, pick your output, copy it. Converting a file to Base64 works on any type here, and the MIME header is filled in for you.
Watch the size. A third is added to everything, and payload limits arrive sooner than you think.
Related Tools You Might Like
Case Converter
Convert text between UPPERCASE, lowercase, Title Case, and more
Password Generator
Generate secure, random passwords with custom options
Word Counter
Count words, characters, paragraphs, and reading time
Base64 Encoder & Decoder
Encode and decode Base64 for text, files, and images with Data URI output
Base64 to File
Decode a Base64 string into a real file, with the type read from its header bytes
Regex Tester
Test and validate regular expressions with live preview
