Choose text or a file
Text encodes and decodes in the first box; files and images in the second.
Encode text to Base64 or decode it back, and convert whole files and images into Base64 or a data URI. You can also turn Base64 back into a downloadable file.
100% private — everything is converted in your browser and nothing is uploaded.
100% private — everything is converted in your browser and nothing is uploaded.
Guides: What is Base64? Encoding, not encryption · How to read a JWT, and why decoding is not verifying
Keep going with your result in another tool. Nothing is uploaded.
Text encodes and decodes in the first box; files and images in the second.
URL-safe, line breaks, or a data URI prefix, depending on where you will use it.
Copy the Base64, or download the decoded file.
Base64 is a way of writing any data, including files, images and arbitrary bytes, using only 64 safe characters: letters, digits, plus and slash. That makes it possible to send binary content through channels that only handle text, such as email bodies, JSON documents, URLs, HTML and CSS, configuration files and HTTP headers. It is also how a small image can be embedded directly in a web page as a data URI. Encoding makes the data about a third larger, and it is a format, not encryption: anyone can decode it.
The first section converts text. Text is first turned into UTF-8 bytes, so accented letters, symbols and emoji encode and decode correctly, which is where quick tools often go wrong. Pasting Base64 and choosing decode gives you back the text. If the decoded data is not valid text, for example because it is an image, the tool says so and points you to the file section.
Standard Base64 uses + and /, which have special meanings in URLs, and ends with = padding. The URL-safe variant replaces them with - and _ and drops the padding, and is used in JSON Web Tokens and in links. The MIME variant breaks the output into lines of 76 characters, as email requires. Decoding accepts all of these forms and ignores spaces and line breaks.
The second section encodes a whole file. Choose a file and you get its Base64, optionally with the data: prefix that turns it into a data URI you can paste into an HTML img tag or a CSS url(). Images are previewed, and the size increase is shown. The reverse direction takes Base64 or a data URI, detects the type of file from its first bytes, and lets you download it with a name of your choice, useful for recovering an attachment or an image embedded in a document.
Base64 is not a way to protect data: it hides nothing. Big files make very long strings, and embedding large images as data URIs slows a page down more than referring to a file. Files above 100 MB are not accepted, since everything is processed in memory. For percent-encoding of URLs, use the URL encoder.
Base64 works on bytes, so text has to become UTF-8 bytes first, which is what the tool does. Each snippet below was run and the comments show the real output.
import base64
text = "Hello, UtilsDock! Grüße"
encoded = base64.b64encode(text.encode("utf-8")).decode("ascii")
print(encoded) # SGVsbG8sIFV0aWxzRG9jayEgR3LDvMOfZQ==
print(base64.b64decode(encoded).decode("utf-8")) # Hello, UtilsDock! Grüße
print(base64.b64encode(b"\xfb\xff\xfe").decode()) # +//+
print(base64.urlsafe_b64encode(b"\xfb\xff\xfe").decode()) # -__-
const text = "Hello, UtilsDock! Grüße";
const bytes = new TextEncoder().encode(text);
const encoded = btoa(String.fromCharCode(...bytes));
console.log(encoded); // SGVsbG8sIFV0aWxzRG9jayEgR3LDvMOfZQ==
const decoded = new TextDecoder().decode(Uint8Array.from(atob(encoded), c => c.charCodeAt(0)));
console.log(decoded); // Hello, UtilsDock! Grüße
// Node.js only:
console.log(Buffer.from(text, "utf-8").toString("base64")); // SGVsbG8sIFV0aWxzRG9jayEgR3LDvMOfZQ==
printf '%s' 'Hello, UtilsDock!' | base64 # SGVsbG8sIFV0aWxzRG9jayE= printf '%s' 'SGVsbG8sIFV0aWxzRG9jayE=' | base64 --decode # Hello, UtilsDock!
btoa() only accepts characters up to code 255. btoa("€") throws an InvalidCharacterError, which is why the JavaScript example turns the text into UTF-8 bytes first.-__- is the URL-safe form of +//+: the same bytes with - and _ instead of + and /, which is what JWTs and many URLs use.printf '%s' rather than echo in the shell: echo adds a line break, and that break gets encoded too.base64.b64encode: base64.b64encode("Hello".encode("utf-8")).decode("ascii") returns SGVsbG8=. base64.b64decode reverses it.More utilities that also run without leaving your browser.