Home / Free tools / Text & Data / Base64 Encode and Decode
Base64 Encode and Decode
Encode text or a file to Base64, or decode Base64 back to text or a file. UTF-8 safe, with URL-safe and padding options. Nothing leaves your browser.
Runs in your browser. Nothing you paste or choose is uploaded or stored.
What this Base64 tool does
Base64 turns any data into a string made only of letters, digits and two symbols, so that it can travel through systems built for plain text, such as email, JSON, URLs and HTML. This page encodes text or a file to Base64 and decodes Base64 back to text or to a downloadable file. It handles accented letters, emoji and other non-English text correctly, tolerates the line breaks and missing padding that real-world data often has, and runs entirely in your browser.
Base64 is an encoding, not encryption. Anyone can decode it in a second, so it must never be used to hide a password or a secret. Its only job is to make binary data safe to carry.
How Base64 works
The input is read as bytes. Every three bytes (24 bits) are split into four groups of six bits, and each group of six bits, a number from 0 to 63, is replaced by one character of a 64-character alphabet: A to Z, a to z, 0 to 9, plus and slash. If the input does not divide evenly by three, the end is padded with one or two equals signs so that the output length is a multiple of four. Because three bytes become four characters, the encoded text is about one third larger than the original. The scheme is defined in RFC 4648.
- URL-safe Base64 replaces plus and slash with hyphen and underscore, so the result can sit in a web address or file name without further escaping. JSON Web Tokens use this variant and drop the padding.
- Line wrapping at 76 characters is the MIME form used inside email messages (RFC 2045). Most other uses want a single unbroken line.
- Text is encoded as UTF-8 first. That is why a plain browser function such as
btoafails on letters like "ż" or "€": it only accepts single-byte characters. This tool converts the text to UTF-8 bytes before encoding, so what you decode elsewhere matches what you typed.
Worked example
The text Man is three bytes: 77, 97 and 110. In binary that is 01001101 01100001 01101110. Regrouped in sixes it is 010011, 010110, 000101 and 101110, which are 19, 22, 5 and 46. In the alphabet those are T, W, F and u, so Man encodes to TWFu. The word Hello has five bytes, one more than a multiple of three, so its output ends with one equals sign: SGVsbG8=. The test suite for this page checks these values, and all the examples in RFC 4648, for example foobar to Zm9vYmFy.
Decoding: what the tool forgives
When you decode, the tool ignores spaces and line breaks, accepts both the standard and the URL-safe alphabets, fills in missing padding, and strips a data URI prefix such as data:image/png;base64,. If the decoded bytes are valid UTF-8 text, you see the text. If they are not, for example when the Base64 is a PNG image or a PDF, the tool says so and offers the bytes as a download instead of showing garbage. A character that is not part of Base64 is reported with its position.
Common uses
- Embedding a small image directly in HTML or CSS. The image to Base64 converter does this with a picture and gives ready-to-paste snippets.
- Reading the payload of a JWT or an API token, which is URL-safe Base64 of a JSON document. Paste a segment, decode it and tidy the result with the JSON formatter.
- Sending binary content inside JSON or XML, as many APIs do for attachments.
- Putting data into a web address, where you may also need the URL encoder and decoder.
Privacy and limits
Nothing you enter or open is uploaded or stored. Files up to 10 MB can be encoded; the tool tests round trips of several megabytes on every release. Because Base64 is not encryption, treat decoded or encoded text with the same care as the original. Other free utilities live on the Text and data page.
Questions
Is Base64 a form of encryption?
No. It is a reversible encoding that anyone can undo without a key. Do not use it to protect passwords, tokens or personal data.
Why is the Base64 output longer than the input?
Three bytes become four characters, so the output is about 33% larger, plus a little for padding and line breaks. This is the price of using only characters that survive in text systems.
What is the difference between standard and URL-safe Base64?
Standard Base64 uses plus and slash, which have special meanings in web addresses. The URL-safe variant uses hyphen and underscore instead, and often leaves out the equals padding.
Why does decoding show a message about binary data?
The bytes you decoded are not valid UTF-8 text, which usually means the Base64 contained an image, PDF, archive or other file. The tool offers it as a download so that nothing is garbled.
Does it support accented letters and emoji?
Yes. Text is converted to UTF-8 before encoding and decoded as UTF-8, so Polish, German, Chinese and emoji text survive a round trip.
Why does the decoder accept input without equals signs?
Padding carries no information; the length of the data already shows how many bytes the last group holds. Many systems drop it, so the decoder adds it back instead of failing.
Is my data sent to a server?
No. Encoding and decoding happen in your browser, and files are read locally and not uploaded.
Google, Merchant Center, YouTube, LinkedIn, Indeed, Glassdoor and Shopify are trademarks of their owners. Van Born Labs is independent and not affiliated with them. Google's own help pages are the final word on its rules.