File to Base64 encoder
Encode a file or text to Base64 in your browser: nothing is uploaded, there is no limit on how many files you encode, and you can add a data URI prefix, make the output URL-safe or wrap lines at 76 characters.
Drop your file here
Elk soort bestand · of plak met Ctrl+V
How it works
-
Choose a file or type text
Drop a file in the box, choose it on your device or type text.
-
Encoded instantly
The Base64 result appears at once; change the options if you like.
-
Copy or download
Copy the text with one click or save it as a .txt file.
What is Base64?
Base64 writes binary data using only letters, digits, + and /, so it can travel through systems that only handle text: email bodies, JSON fields, HTML attributes and URLs. The price is size: Base64 text is about a third larger than the original file.
Options
- Data URI adds
data:image/png;base64,(or the right type for your file), so you can paste the result straight into ansrcorurl(). - URL-safe swaps
+and/for-and_and drops the=padding (base64url, as used in JWTs). - Wrap lines at 76 characters gives the classic MIME layout used in email.
Where Base64 is used
- Data URIs in HTML and CSS: a small image or font written directly in a
srcorurl(). For images there is also image to Base64, which gives HTML and CSS snippets. - JSON and APIs that only accept text: file contents sent as a string.
- Email (MIME), which is why the classic format wraps lines at 76 characters.
- Tokens and keys in the URL-safe form, as in the parts of a JWT.
Check the size first
Base64 makes data about 33% bigger. A 3 MB file becomes 4 MB of text. That is fine for a small icon, but embedding a large image in a page makes the page slower than a normal file would. A rule of thumb: keep embedded data under about 10 KB.
Text instead of a file?
To encode a piece of text, you can type or paste it straight into this tool, or use text to Base64. Need the way back? Base64 to file turns the text into a download again.
Private by design
The file is read and encoded in your browser. It never leaves your device. Very long results are shortened on screen, but Copy and Download always include everything.
Frequently asked questions
What is the difference between normal Base64 and URL-safe?
URL-safe Base64 uses - and _ instead of + and /, and has no = padding, so it can be placed in a web address or a JWT without being escaped.
How much bigger does Base64 make my file?
About a third: every 3 bytes become 4 characters.
When should I add a data URI prefix?
When you paste the result in a src attribute or a CSS url(). The prefix tells the browser what kind of file it is.
Is my file uploaded?
No. It is read and encoded in your browser and never leaves your device.