Base64 Encoder and Decoder

Encode any text as Base64, or decode a Base64 string back into readable text, as you type. The tool is free, handles UTF-8 and the URL-safe alphabet, and runs entirely in your browser so nothing you paste is uploaded.

Base64 Encoder and DecoderPrivate · runs on your device
Input
Words 0Characters 0Lines 0
Result

Example: Hello → SGVsbG8=

How to use the Base64 encoder and decoder

The tool converts text in one direction at a time, and the result updates as you type.

  1. Paste or type your text into the Input box, or press Paste to take it from the clipboard.
  2. Set Mode to Encode to turn text into Base64, or to Decode to read a Base64 string.
  3. Tick URL-safe alphabet if the result will sit in a link, a filename or a JSON Web Token. It swaps + and / for - and _ and drops the = padding. The box only changes encoding.
  4. Read the result in the output box. If a decode input is not valid Base64, a short error note appears instead.
  5. Press Copy or Download .txt, or Use as input to send the result back in and flip the mode to check a round trip.

Decoding is forgiving: it accepts both alphabets, restores missing padding and ignores spaces and line breaks. Encoding produces one unbroken line, without the 76-character wrapping that email attachments use.

How Base64 turns bytes into characters

Base64 writes binary data using 64 printable characters: A to Z, a to z, 0 to 9, + and /. The encoder takes three bytes (24 bits), cuts them into four groups of six bits, and looks each group up in that alphabet. In Hel the bytes 01001000 01100101 01101100 become the groups 18, 6, 21 and 44, which are S, G, V and s. The leftover lo gives bG8, and a single = pads the final block to four characters.

One leftover byte earns two = signs, two leftover bytes earn one. Output length is the byte count divided by three, rounded up, then multiplied by four, so Base64 is about a third larger than the original. Text is converted to UTF-8 bytes first, so accents and emoji survive the trip.

InputBytesBase64
Hello5SGVsbG8=
Hello, world!13SGVsbG8sIHdvcmxkIQ==
€34oKs
user:pass9dXNlcjpwYXNz

Where Base64 appears, and the URL-safe variant

Base64 exists to carry bytes through channels built for text. You meet it in HTTP Basic authentication, where user:pass becomes Authorization: Basic dXNlcjpwYXNz, in email attachments, and in the first two parts of a JSON Web Token. Decoding eyJhbGciOiJIUzI1NiJ9 here, which is URL-safe and unpadded, gives {"alg":"HS256"}. To read a whole token with its claims laid out, use the JWT decoder.

The standard alphabet contains +, / and =, which have jobs of their own inside URLs. The URL-safe form swaps them out: the text subjects?>> encodes as c3ViamVjdHM/Pj4= in the standard alphabet and c3ViamVjdHM_Pj4 in the URL-safe one. If you only need to escape characters for a query string, the URL encoder is the right tool. This page takes text only, so for pictures use the image to Base64 converter.

Mistakes to avoid

  • Treating it as encryption. Base64 has no key. Anyone can reverse it, so it hides nothing. For a one-way fingerprint use the hash generator.
  • A stray newline. A trailing line break is part of the input: Hello plus a newline encodes as SGVsbG8K, not SGVsbG8=. This is why command-line results sometimes disagree with a web tool.
  • Expecting text from binary. If the decoded output shows diamond replacement characters, the data was probably an image, archive or other binary file, not text.
  • Damaged input. A string whose length leaves a remainder of one after dividing by four cannot be valid, usually because characters were lost when it was copied.
  • Two alphabets in one string. Mixing + with -, or / with _, is a sign that two sources were joined. The decoder accepts either, but other software may not.
  • Assuming a file can be pasted. Base64 of a large file is a very long string. The converter handles plain text, so keep binary files for a tool that reads files directly.

A quick way to test a value is a round trip: encode it, press Use as input, switch Mode to Decode, and confirm the original text returns. If it does, the Base64 you are about to send is sound.

Quick answers

Frequently asked questions

The questions people ask most, answered in plain words.

What does a Base64 encoder do?

It rewrites bytes as 64 printable characters so data can travel through text-only channels such as email, JSON and URLs. Every three bytes become four characters. The decoder reverses this and returns the original bytes, which this page displays as UTF-8 text.

Is Base64 encoding secure?

No. Base64 is an encoding, not encryption. There is no key, and anyone can decode a string in seconds with a page like this one. It makes data safe to transmit, not safe from being read. Use proper encryption for anything confidential.

Why does Base64 end with equals signs?

Padding. Base64 works in blocks of three input bytes that become four characters. If the last block has only one or two bytes, the output is padded with two or one equals signs. They carry no data, which is why the URL-safe option drops them.

What is URL-safe Base64?

It is a variant that replaces plus with a hyphen and slash with an underscore, and usually omits the equals padding. Those three characters have special meanings in URLs, so the URL-safe form can sit in a link, filename or token without extra escaping.

Why is my decoded Base64 unreadable?

Most often the original data was not text, such as an image or a compressed file, so its bytes have no sensible characters. It can also mean the string was cut short or altered. Check that only valid Base64 characters remain and that nothing was truncated.