File to Base64
Convert any file — audio, video, PDF, images — to Base64 or a data URI.
This tool runs entirely in your browser. Your data is never uploaded, never stored, and never leaves your device.
Turns any file — an MP3, a PDF, a video, a spreadsheet, an image — into its Base64 text form, offered either as a complete data: URI or as the raw payload on its own.
How to use it
- 1Click the drop area, or drag a file onto it; files over 20 MB are refused with "File is too large (max 20 MB)."
- 2Switch between Data URI and Raw Base64 — the second strips everything up to and including the comma.
- 3Read the size line to see what the encoding cost, then press Copy.
Example
- Input
- a 240 KB PDF
- Output
- data:application/pdf;base64,JVBERi0x… — roughly 320 KB of text
Base64 costs about a third more than the bytes it encodes. Every PDF starts JVBERi0x because that is %PDF-1 encoded, and the MIME type in the prefix is whatever your operating system reported for the file, not something sniffed from the contents.
What happens to your data
The file is read with FileReader.readAsDataURL, so the browser produces the Base64 itself and no multipart request is ever built. The size check happens before the read is started, which means an oversized file is never loaded into memory at all; above 500,000 characters the visible box shows a truncated preview marked as such, while Copy still hands over the full string held in state.
Last updated August 2026
An API field wants the document as a string rather than as an upload. A stylesheet needs one small icon inlined so the page does not fetch it separately. An automation step will carry text and nothing else, and the file has to go through it anyway. Base64 is what all three are asking for: the same bytes, rewritten in characters that survive being pasted into JSON, YAML, HTML or an email body.
Decide before you start which of the two outputs the thing at the other end expects, because they are not interchangeable. A data URI carries the type in front of the payload — data:application/pdf;base64, and then the text — and that whole string is what belongs in a CSS url() or an img src, because the browser has to be told what it is looking at. The raw payload on its own is what almost every API, config file and database column means when it asks for something Base64 encoded. Sending the full data URI where the bare payload was wanted is the most common mistake by a distance: the decoder at the far end either refuses it outright or writes a file whose first bytes spell out the word data.
Two things the format cannot do, whatever you read elsewhere. It does not compress — the text is always larger than the file it came from. And it does not protect anything: there is no key, and anyone holding the string can turn it back in a single step. A credential Base64-encoded into a config file is obscured from a passing glance and from nothing else.
How it works
Toolvore hands the file to the browser's own reader and keeps the single string that comes back; everything on screen after that is a view of that one result rather than a second pass over your file. The raw view is a substring of the same stored string, worked out as you look at it, which is why the figure describing the output shrinks when you switch views — it measures the text currently in the box, prefix and all. One file at a time is the whole model: the picker takes a single file, and choosing another clears the previous output rather than adding to it. A file the browser cannot read leaves a short message where the output would be. The gaps worth knowing before you rely on it: the text comes out as one unbroken line with no folding at 76 characters, so it is not ready to drop into an email body that expects wrapped MIME; there is no URL-safe alphabet, so plus and slash characters come through as they are; nothing is compressed along the way; and there is no download of the result as a file, so the output leaves by the Copy button or not at all.
Common use cases
- Inlining a small icon or logo in a stylesheet to save a request
- Putting a PDF into a JSON API field that only accepts a string
- Embedding a sample file in a test fixture so the suite carries no binary
- Moving a document through an automation step that passes text only
- Filling in a Base64 field in a YAML or environment config by hand
- Pasting an image into an HTML file that has to travel on its own
- Checking what the opening characters of an encoded file look like
Frequently asked questions
What is Base64 encoding, and why does anything still use it?+
Base64 takes bytes three at a time and rewrites them as four characters from a fixed set of 64 — the letters in both cases, the digits, plus and slash — with one or two equals signs at the end when the input does not divide neatly by three. It exists because much of the internet was built to move text: email bodies, JSON, XML, HTTP headers, YAML config. Push raw bytes through any of those and something along the way mangles them. Dressing the bytes up as ordinary characters means they arrive intact and can be turned back at the far end, at the cost of carrying more of them.
Why is the Base64 text bigger than the file it came from?+
Four characters for every three bytes is a fixed ratio, so the text is always longer, and that is arithmetic rather than waste. Padding adds a character or two on top. The growth compounds where people forget to look: put the string in JSON and the transport counts the larger figure, store it in a text column and the database stores the larger figure, attach it to an email and the limit applies to the encoded size. If you need it smaller, compress the file and encode the compressed result — the other order gains far less, because encoded text leaves a compressor very little to find.
Is Base64 a form of encryption?+
No, and the confusion does real damage. There is no key and no secret — the alphabet is published, every language ships a decoder, and reversing the string is one step anyone can take. An API key or password stored Base64-encoded is hidden from a passing glance and from nothing more determined. Kubernetes secrets are the classic trap, stored as Base64 by default and routinely mistaken for encrypted ones. Encode when a channel needs text; encrypt when something needs to stay private. The two answer different questions, and encoding is not a weaker form of encryption.
Does my file get uploaded anywhere when I encode it?+
No. The reading happens inside the browser and there is no upload step in the tool at all — no request carries the contents, and no server holds a copy for you to worry about later. The encoded string lives in the page's memory and nowhere else: it is not written to storage, it is not put in the address bar, and refreshing or closing the tab loses it. Copy takes the complete string from that same memory rather than from what is drawn on screen. The distinction matters for what people usually bring here, which is more often a signed document or a credential than a holiday photo.
Why does my decoded file come out corrupted?+
Nearly always the string rather than the file. The commonest cause is leaving the data: prefix in front of a payload when the decoder wanted the payload alone — those letters decode as bytes and the file header is wrong from its first character. Next is stray whitespace, since a string copied from a wrapped email or a terminal arrives with newlines and strict decoders refuse them. Then missing equals padding, which some decoders demand and others tolerate. Then hyphens and underscores from a URL-safe string fed to a standard decoder. And when you decode back, the bytes carry no name — the extension you save under is what decides how it opens.
Should I inline images as data URIs in CSS or in email?+
In CSS, for small icons and simple SVGs, it is a fair trade: one fewer request, and the image arrives with the stylesheet. Past that it turns against you. An inlined image cannot be cached separately, so every change to the stylesheet re-sends the picture with it, and nothing downloads in parallel because the bytes sit inside a file that blocks rendering. A large photograph inlined this way is a mistake every time. In email, check before you rely on it: several clients, Gmail among them, will not render a data URI image, so an inlined logo shows as nothing at all.
What is URL-safe Base64, and when do I need it?+
Standard Base64 uses plus and slash, and both mean something else in a URL — a slash separates path segments, and a plus is read as a space by anything decoding a query string as form data. RFC 4648 therefore defines a URL-safe alphabet using hyphen and underscore in their place, usually with the equals padding dropped. The segments of a JWT are written that way. What the browser produces here is the standard alphabet, so for a URL, a filename or a header you will need to swap those two characters yourself, and be ready to restore the padding before decoding.
How large a file is worth encoding this way?+
Files over 20 MB are refused here, and the sensible ceiling for most uses sits well below that. The encoded value is one long string held in memory, so multi-megabyte values make editors, log viewers and browser tooling sluggish. Many APIs cap a request body at a few megabytes and apply that cap to the encoded size, which is the larger figure. Email catches people the same way: a 24 MB attachment against a 25 MB limit fails, because what travels is the Base64 version. Where a file is genuinely large, send a link to it instead — inlining only pays when fetching separately would cost more.
Related tools
Base64 Encode/Decode
Encode text to Base64 or decode Base64 back to text.
UUID Generator
Generate one or many random UUID v4 identifiers.
Password Generator
Generate strong, random passwords with custom rules.
Morse Code Translator
Convert text to Morse code and back, with audio playback.