Кодирование файла в Base64 строку
Tool guide
Pick a file and the page hands back its Base64 form — the long string you drop into an src attribute, a CSS background-image rule, or a JSON field when an API expects an inline attachment. Any type works: images, fonts, PDFs, archives. Nothing is uploaded; the browser reads the file locally and the encoded text appears in the output box ready to copy. See also: decode Base64 back into a file, inline an image as a data URI, encode a plain string to Base64.
About 33 percent. Every three bytes of input become four text characters, plus padding at the end, so a 90 KB image yields roughly 120 KB of string. That overhead is exactly why inlining makes sense for small icons and rarely for photographs.
All of them — there is no extension filter. PNG, SVG, a woff2 font, a PDF, a ZIP or a docx all encode the same way, because Base64 works on raw bytes and does not care what they mean. The format only matters later, when the data: prefix has to carry the correct MIME type.
Usually not. An inlined image cannot be cached separately from the stylesheet, it inflates the CSS file, it delays first paint and the browser cannot fetch it in parallel. A few kilobytes is a sensible ceiling — a logo, an icon, a tiny texture. Anything bigger is better served as its own cacheable file.
No. The browser's own file reader opens it inside the tab and the bytes are encoded on the same page. Neither the file nor the resulting string is sent out, so internal documents can be encoded without leaving your machine.
That is almost always the destination, not the encoding. Some editors and form fields cap the length of pasted text or fold very long lines. Use the copy button rather than a mouse selection, turn off soft wrapping in your editor, and check that the pasted text ends where the output box does.
Yes — on mobile it opens the gallery or the file manager, and the result copies with one tap. Bear in mind that a camera photo is several megabytes, so the string will be enormous and a modest device may stall for a few seconds while it is produced.
Before: favicon-16.png, 412 bytes
After: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQ..."); Before: contract.pdf, 84 KB
After: {"filename": "contract.pdf", "content": "JVBERi0xLjQKJcfsj6IKNSAwIG9iag..."} Your rating and feedback help decide what to improve next.