File to Base64
Convert any file to Base64 or a data URL. Choose your file, pick raw Base64 or data URL output, then copy. Free, no signup, runs in your browser. Your file never leaves your device.
Preview
Preview will appear here when you select an image file.
Need the opposite? Decode Base64 to file.
How to convert file to Base64
- Click Choose file or drag and drop a file. Any file type is supported (images, PDF, text, etc.).
- Choose Raw Base64 (only the encoded string) or Data URL (e.g.
data:image/png;base64,...) for use in HTMLsrcor CSS. - The converted result appears in the text area. Use Copy to clipboard to paste it into your code or app. A preview is shown for images.
- Conversion runs entirely in your browser; the file is never uploaded. To decode Base64 back to a file, use our Base64 to File tool.
Use this tool to embed small images in HTML or CSS, send binary data in JSON APIs, or store file content as text. For very large files, consider size limits; the browser does all work in memory.
Raw Base64 or data URL: which should I choose?
- Raw Base64 is just the encoded text. Choose it when an API, a JSON field, or a configuration file asks for a Base64 string and you will supply the file type separately.
- Data URL adds a short prefix describing the file type, such as
data:image/png;base64,. Choose it to embed a small image directly in an HTMLimgtag or a CSSbackground-imagewithout a separate file request.
Things to keep in mind
- Base64 is larger than the original. The encoded text is roughly one third bigger than the file, so it is best suited to small files such as icons and thumbnails.
- It is not encryption. Anyone can decode Base64 text, so do not treat it as a way to hide sensitive content.
- Large files use memory. The browser handles everything in memory, so very large files may be slow or fail on older devices.
- Embedding trade-off. Inline data URLs save a network request but cannot be cached separately from the page, so use them sparingly.
Frequently asked questions
- Is my file uploaded to your server?
- No. The file is read and encoded in your browser, and it never leaves your device.
- Which file types work?
- Any file can be encoded. An image preview is shown for pictures, and other file types are encoded without a preview.
- How do I turn the text back into a file?
- Paste it into the Base64 to File tool, which detects the file type and lets you download the result.