SEOLyzerPro

100% Free forever - No account required

Use 47 free online tools: meta tag and robots.txt generators, image and text tools, JSON converters, calculators and unit converters. No signup needed

Base64 Encode

Convert text to Base64

Base64 Encode

What this tool does

The Base64 Encode tool converts text, or other data, into a string made only of letters, numbers and a few symbols. Enter your text, click Encode, and the tool gives you the Base64 version. This is useful when data has to travel through a system that can handle only plain text, such as an email, a web address, a JSON file or an HTML page.

How to use it

  1. Enter or paste your text into the input box.
  2. Click Encode.
  3. Copy the result. Use Reset to start again.

Worked examples

Original text Base64 result
Hello SGVsbG8=
Hello World SGVsbG8gV29ybGQ=
Hello, World! SGVsbG8sIFdvcmxkIQ==
user:pass dXNlcjpwYXNz
café Y2Fmw6k=

The last example shows that characters outside basic English text are encoded as their UTF-8 bytes first, which is why “café” does not give the result you might expect from four letters.

How it works

Computers store text as bytes. Base64 takes the bytes in groups of three, which is 24 bits, and splits them into four groups of 6 bits. Each 6-bit group is a number from 0 to 63, and that number is replaced by one character from a list of 64 safe characters: the letters A to Z, a to z, the digits 0 to 9, and the symbols + and /.

Take the word “Man”. Its bytes are 77, 97 and 110, which in binary make 01001101 01100001 01101110. Splitting those 24 bits into four groups of six gives 010011, 010110, 000101 and 101110, which are 19, 22, 5 and 46. These correspond to the characters T, W, F and u, so “Man” becomes “TWFu”.

Padding

If the input does not divide evenly into groups of three bytes, the tool adds the equals sign (=) at the end as padding, so that the output length is always a multiple of four. One leftover byte gives two equals signs, and two leftover bytes give one. This is why “Hello” ends with one equals sign and “Hello, World!” ends with two.

The output is larger than the input

Every three bytes become four characters, so the encoded text is about one third larger than the original. The exact length is 4 × the next whole number above (bytes ÷ 3). “Hello” has 5 bytes, so the output is 4 × 2 = 8 characters. For this reason, Base64 is not used to make data smaller. It is used to make data safe to transport as text.

Where Base64 is used

  • Email attachments. Email was designed for text, so attachments are converted to Base64 in the MIME standard.
  • Data URIs. Small images can be placed directly in HTML or CSS, for example data:image/png;base64,..., which saves a separate file request for tiny icons.
  • APIs and JSON. JSON can hold only text, so binary data such as a small file is often sent as a Base64 string.
  • HTTP Basic authentication. The header carries “username:password” in Base64, as in the “user:pass” example above. This does not hide the credentials, so it must only be used over HTTPS.
  • Tokens and certificates. Many security formats store their data in Base64.
  • Configuration files that need to hold a binary value as text.

Base64 is not encryption

This is the most important thing to understand. Base64 is only an encoding, a different way of writing the same information, and anyone can reverse it in a second with a decoder. It offers no secrecy. Never use Base64 to protect passwords, personal data or other secrets. For protection, use proper encryption and secure storage.

URL-safe Base64

The characters + and / have special meaning in web addresses, and the equals sign can cause trouble in some places. A URL-safe variant replaces + with a hyphen (-) and / with an underscore (_), and it often leaves out the padding. It is common in tokens and web links. A standard decoder may fail on URL-safe text unless the characters are converted back.

Text, characters and encoding

Different encodings turn the same text into different bytes. Modern systems use UTF-8, which is also the standard for the web, so Base64 of the same text will match between tools that use UTF-8. If another system used a different character set, such as Latin-1 or UTF-16, the Base64 result will differ for any character outside basic English. When two tools disagree, the character set is the first thing to check.

Tips

  • Remove spaces or line breaks that you did not mean to include, because they change the result.
  • Keep the original text. Decoding gives it back, but only if the encoded string is complete and correct.
  • Do not encode large files in an online tool when a program on your own device can do it.
  • Avoid pasting passwords, access tokens, private keys or personal data into any online tool.

Privacy

Encoding happens in your browser and your text is not sent to our server. Do not enter confidential information.

Limits of this tool

The tool changes the format of data. It does not compress, encrypt or protect it, and it does not check whether the data is meaningful. Very long inputs may be slow in older browsers.

Frequently asked questions

Is Base64 secure?
No. It is an encoding, not encryption, and anyone can decode it.

Why does the result end with = signs?
They are padding that makes the length a multiple of four.

Why is the output longer than the input?
Four characters are used for every three bytes, so the output is about 33% longer.

Can I encode an image?
Yes, with a tool that supports files. The result is a long string that you can place in a data URI.

Can I get the original back?
Yes. Use the Base64 Decode tool.

Related tools

Base64 Decode, URL Encode, JSON Formatter, Password Generator, Image Converter and QR Code Generator.