Base64 is a way of writing any data using only 64 plain characters. This tool converts text to Base64 and Base64 back to text. For the example Hello, internet! the encoded result is SGVsbG8sIGludGVybmV0IQ==.
Text is handled as UTF-8, so accented letters, non-Latin scripts and emoji survive the trip in both directions. Encoding and decoding both happen in your browser, which the page states with the line "Processed in your browser". The IP Tracker server does not receive what you type.
How to encode or decode text
- Type or paste your text into the large box. It can be up to 10,000 characters long.
- Set Operation to Encode to turn text into Base64, or to Decode to turn Base64 back into text.
- Click Run tool.
- Read the result row. It is labeled Base64 after encoding and Text after decoding.
- Copy the value from the row, or use "View as JSON", Copy JSON or Download JSON under it.
When you decode, spaces and line breaks in the input are ignored. Base64 that was wrapped over several lines, as it is in emails and certificate files, can be pasted without joining the lines first.
When you encode, every character in the box counts, including a space or a line break at the end. A stray line break changes the output.
How to read the result
After encoding, the Base64 row holds a string made of letters, digits, + and /, possibly ending in one or two = signs. Its length is always a multiple of four.
After decoding, the Text row holds the original text. If the page shows an error instead, one of two things is wrong. Either the input contains characters that are not part of Base64, or it is valid Base64 that does not decode to text. The second case is normal for Base64 that carries a file, an image or a cryptographic key: the bytes are real, but they are not readable characters.
What Base64 is for
Many systems were built to carry text and nothing else. They may change line endings, drop characters they do not recognize, or give special meaning to quotes, angle brackets and control codes. Raw binary data, such as an image, does not survive that. Base64 rewrites the data with 64 characters that pass through nearly everything unchanged.
- Email attachments. Mail was designed for plain text, so attachments travel as Base64 inside the message.
- Data URLs. A small image or font can be placed directly in a web page or style sheet as
data:image/png;base64, followed by the encoded file. - JSON and XML fields. These formats have no type for binary data, so APIs put files, signatures and keys into string fields as Base64.
- HTTP basic authentication. The browser joins the username and password with a colon, encodes the result and sends it in the
Authorization header. user:pass becomes dXNlcjpwYXNz. - Certificates and keys. The text files that begin with
-----BEGIN CERTIFICATE----- contain Base64 between the marker lines.
How the encoding works
Base64 reads the input three bytes at a time. Three bytes are 24 bits. It cuts those 24 bits into four groups of 6 bits, and a 6-bit group can hold a value from 0 to 63. Each value is then replaced by one character from a fixed alphabet.
The text Hi! shows the steps. Its three characters are the bytes 72, 105 and 33.
Decoding runs the same steps backward: characters to numbers, numbers to bits, bits regrouped in eights.
Before any of this, text has to become bytes. The tool uses UTF-8, in which plain English letters take one byte each and other characters take two to four. The word café has four characters but five bytes, because é takes two, and it encodes to Y2Fmw6k=.
Padding and size
Input does not always come in multiples of three bytes. When one or two bytes are left over at the end, the encoder fills the last group of four characters with = signs. The padding tells the decoder how many bytes the final group really holds.
Four output characters for every three input bytes means the encoded form is about one third larger than the original. The 16 characters of Hello, internet! become 24. A 300 KB image becomes about 400 KB when it is embedded as a data URL, which is why the technique suits small files only.
Formats that wrap Base64 into lines add a little more, since each line break is an extra character.
Base64 is not encryption
Encoding and encryption are different things. Encryption needs a secret key to reverse. Base64 needs nothing: anyone who sees the string can decode it, with this page or with one line of code. The only thing it prevents is reading the data at a glance.
This matters most with credentials. The basic authentication header mentioned above carries the password in a form that decodes in a moment, so it is safe only over HTTPS, where the whole request is encrypted. The same goes for tokens and API keys that happen to be stored as Base64 in a configuration file. Treat the encoded form with the same care as the plain one.
Be careful where you paste encoded secrets. This tool decodes in your browser and does not send the input to the IP Tracker server.
Common problems with Base64 strings
- The string contains
- or _. That is the URL-safe variant of Base64, used in web addresses and in JSON Web Tokens because + and / have special meanings in a URL. This tool uses the standard alphabet, so replace every - with + and every _ with / before decoding. - The string came out of a web address and contains
%2B, %2F or %3D. Those are the percent-encoded forms of +, / and =. URL Parser shows query parameters already decoded. A bare + in a query string means a space, so a value that was not percent-encoded can arrive with spaces where its plus signs should be. - The result of decoding is more Base64. Data is sometimes encoded twice. Decode the result again.
- The output of a command does not match the tool.
echo adds a line break to its text, so echo hello | base64 encodes six bytes and gives aGVsbG8K, while the five letters alone give aGVsbG8=. Use printf in place of echo to leave the line break out. - The tool reports an error for a string that looks correct. In that case the data may be binary. For example, the
p= value of a DKIM record, which TXT Lookup shows, is a public key in Base64, and it decodes to key bytes, not to text.
What this tool does not do
It works on text. It does not encode files, and it cannot display decoded data that is not UTF-8 text, such as an image or a compressed archive.
It uses the standard alphabet with = padding and has no option for the URL-safe variant. Input is limited to 10,000 characters.
It does not interpret what it decodes. A certificate is binary underneath its Base64, and to read the certificate a website presents you need SSL Checker. A JSON Web Token has three parts separated by dots. The first two decode to JSON text once you convert them from the URL-safe variant, and the third is a binary signature.
Frequently asked questions
Is Base64 a form of encryption?
No. Base64 has no key and no secret. It is a public, fixed way of rewriting data, and anyone can reverse it.
If you need to keep something confidential, encrypt it. Encrypted data is often Base64-encoded afterwards so that it can be sent as text, and that is how the two get mixed up.
Why does Base64 end with one or two equals signs?
The equals signs are padding. Base64 output comes in blocks of four characters, each block standing for three bytes. When the input ends with one byte left over, the last block gets two = signs. With two bytes left over it gets one.
When there is no padding at all, the length of the data was a multiple of three bytes.
Why is the encoded text longer than the original?
Each Base64 character carries 6 bits, while a byte holds 8. It takes four characters to carry three bytes, so the output is about 33 percent longer. Text with accented letters or non-Latin scripts grows more than that compared with its character count, because those characters take several bytes each before encoding starts.
What is the difference between Base64 and Base64URL?
Two characters. Standard Base64 uses + and / for the values 62 and 63. Base64URL uses - and _ instead, because the standard pair has special meanings in web addresses. Base64URL strings also often leave off the = padding.
This tool uses the standard alphabet. To decode a Base64URL string, swap the two characters back first.
Why do I get an error when I decode?
Check the input for characters outside the Base64 alphabet. Common culprits are - and _ from the URL-safe variant, percent signs left over from a web address, and quotation marks copied along with the string.
If the characters are all valid, the data is probably not text. The tool shows decoded data only when it is valid UTF-8 text.
Can I decode an image or a file with this tool?
No. It decodes Base64 to text only. The bytes of an image, a PDF or an archive are not text, so the tool reports an error and has no way to save them as a file.
How can I tell whether a string is Base64?
Look at its shape. Base64 uses only letters, digits, + and /. With padding, its length is a multiple of four, and it may end in = or ==. A long string with no spaces and a mix of upper and lower case is a likely candidate.
The shape is a hint and not proof. An ordinary word such as test also consists of valid Base64 characters. Decoding is the real check: if readable text comes out, the string was Base64-encoded text.
Is my text uploaded when I use this tool?
No. Encoding and decoding are done by your browser, and the input is not sent to the IP Tracker server. IP Tracker does not keep a history of what visitors enter.