Encoding Tools

Base64 Encoder / Decoder

Encode UTF-8 text or decode Base64, including Unicode.

Browser workspace
LOCAL PROCESSING

Input stays in this browser while you use the tool.

About this tool

The Base64 Encoder / Decoder converts text to Base64 and Base64 back to text. Base64 is a way of writing binary data, or any text, using only 64 safe characters: the letters A to Z and a to z, the digits 0 to 9, and the symbols + and /. An equals sign = may appear at the end as padding.

It exists because many systems were built to carry plain text only. Email, URLs, HTML attributes and JSON fields can break or change data they do not expect. Writing the data as Base64 lets it pass through safely and be restored exactly on the other side. You will meet it in data URIs, email attachments, HTTP Basic authentication headers and JSON Web Tokens.

Base64 is an encoding, not encryption. Anyone can decode it, and it gives no protection to the data. The result is also about one third longer than the original.

This tool encodes text as UTF-8 first, so accented letters, other alphabets and emoji work correctly. It runs in your browser, and the text is not sent to the BitToolsKit server.

Use cases

  • Read an encoded value from an API or a log. Paste the string and decode it to see what it contains.
  • Check an Authorization header. HTTP Basic authentication sends username:password as Base64. Decoding shows what a request actually contains, which is also why that header needs HTTPS.
  • Prepare text for a place that only accepts safe characters. Encode a value before placing it in a URL parameter, a configuration file or a JSON string.
  • Inspect parts of a token. The sections of a JSON Web Token are Base64 text. Decoding a section shows its JSON.
  • Test your own code. Compare the output of your encoding function with a known correct result.
  • Learn how Base64 works. Encode very short strings and see how the output and the padding change.

How to use

  1. Choose whether you want to encode or decode.
  2. Paste your text, or your Base64 string, into the Input box.
  3. Click Run tool.
  4. Read the result in the Output box. When encoding, you get a Base64 string. When decoding, you get the original text.
  5. If a message appears when decoding, the input is not valid Base64. Check it against the common errors below and run the tool again.
  6. Click Copy output to copy the result, Download to save it, or Clear to start again.

When you decode, remove anything that is not part of the Base64 itself, such as the data:...;base64, prefix of a data URI or a quotation mark around the value.

Examples

Example 1: Encode text

Input (Encode):
Hello, World!
Output:
SGVsbG8sIFdvcmxkIQ==

Example 2: Decode text

Input (Decode):
SGVsbG8sIFdvcmxkIQ==
Output:
Hello, World!

Example 3: Accented characters

Input (Encode):
Café
Output:
Q2Fmw6k=

Example 4: How padding works (three separate runs)

Input (Encode):
M
Ma
Man
Output:
TQ==
TWE=
TWFu

Common errors

An error says the input is not valid Base64

Valid Base64 uses only letters, digits, +, / and = at the end. Look for quotes, commas, a data URI prefix or other characters that do not belong, and remove them.

The padding at the end is missing

A Base64 string normally has a length that is a multiple of 4, filled with = at the end. Some systems drop the padding. Add one or two = signs until the length is a multiple of 4.

Line breaks or spaces inside the Base64

Email and PEM files often wrap Base64 into lines of 64 or 76 characters. Remove the line breaks and spaces if the tool does not accept them.

The string contains - and _ instead of + and /

This is URL-safe Base64, used in URLs and JSON Web Tokens. Replace - with + and _ with /, and add padding, before you decode with a standard decoder.

The decoded text looks garbled

The Base64 may hold binary data, such as an image, a file or compressed bytes, which is not readable text. Garbled output can also mean the original text was encoded with a different character set, not UTF-8.

Special characters give a different result than in your code

Some systems encode text as Latin-1 or another character set instead of UTF-8. The same word can then produce a different Base64 string. Make sure both sides use UTF-8.

The data URI prefix is included

A value such as data:image/png;base64,iVBOR... has a prefix. Only the part after the comma is Base64. Decode that part.

Plus signs changed to spaces

In URLs and form data, a + can be read as a space. If a copied Base64 string contains spaces where + should be, replace them with + before decoding.

Using Base64 as if it were encryption

Base64 hides nothing. Anyone can decode it in seconds. Use real encryption for secrets, and never treat a Base64 string as protected.

Encoding the same value twice

If decoded text still looks like Base64, it was probably encoded twice. Run the decoder again on the result.

Frequently asked questions

What is Base64?

It is a way of writing data using 64 safe text characters, so that it can pass through systems that only handle plain text. The data can be restored exactly by decoding it.

Is Base64 encryption?

No. It is an encoding that anyone can reverse without a key. Do not use it to protect passwords or private data.

Why does Base64 sometimes end with = or ==?

Base64 turns every three bytes into four characters. When the data is not a multiple of three bytes long, one or two = signs are added to fill the last group.

Why is the result longer than the original?

Every three bytes become four characters, so Base64 text is about 33 percent longer than the data it represents.

Does the tool support Unicode and emoji?

Yes. Text is converted to UTF-8 before encoding, and decoded back from UTF-8, so accented letters, other alphabets and emoji are handled correctly.

What is URL-safe Base64?

It is a variant that uses - and _ instead of + and /, and often leaves out the = padding. This makes it safe to put in URLs and file names. JSON Web Tokens use it.

Can I encode images or files?

This tool works with text. Encoding a file needs the raw bytes of the file, which a text box cannot hold.

Why does decoding give me strange characters?

The Base64 probably holds binary data or text in another character set. Only Base64 that was made from UTF-8 text decodes into readable text.

Is my text uploaded to a server?

No. The tool runs in your browser and works on your device. As a general habit, avoid pasting passwords, API keys or private tokens into any online tool.

Related tools

Share this page