ToolsHub4u

Encode text to Base64 or decode it back

Base64 turns text into a safe alphabet for transport in JSON, URLs and email headers. This page encodes and decodes UTF-8 text, including accents, emoji and scripts outside Latin, without sending the text anywhere.

  • UTF-8 safe
  • URL-safe option
  • Nothing uploaded
Ready Developer & Utility
1Enter
2Adjust
3Copy result

Base64 Encoder

1

Text and options

Direction

Encoding reads the text as UTF-8. Decoding rejects bytes that are not valid UTF-8 text.

Options

URL-safe output replaces + with - and / with _. Wrapping is for email-style text, not for JSON values.

No data yet Live
2

Base64 result

Encoded 49 UTF-8 bytes to 68 Base64 characters.

Base64

  • UTF-8 bytes are encodedCharacters outside ASCII are converted to UTF-8 before encoding, so decoding restores the same text.
  • Standard alphabetThe output uses + and /, which need percent-encoding in a URL query string.
Input characters
40
UTF-8 bytes
49
Base64 characters
68
Size increase
39%

Base64 is encoding, not encryption. Anyone can decode it. It also makes text about a third larger, so it is not a way to compress data.

This page turns text into Base64 and turns Base64 back into text. It reads the input as UTF-8, so accented letters, CJK characters and emoji survive the round trip, and it writes the result in the text area beside the form. Decoding works the other way: paste a Base64 value and the page returns the original text, or explains why the string could not be read.

Both directions run in the tab. The text is not posted to a server, and there is no account or daily limit. The options cover the three variations that cause most confusion in practice: padding, the URL-safe alphabet, and the 76-character line wrapping used by email.

What Base64 does to text

Base64 is a reversible encoding, not a cipher. It takes every three bytes of input and writes them as four characters from a 64-character alphabet: A–Z, a–z, 0–9, + and /. Three bytes hold 24 bits, and four Base64 characters hold the same 24 bits in groups of six. Nothing is added or removed, apart from padding at the end.

Text is not stored as bytes in JavaScript, so the page encodes the UTF-8 form of what you typed. A character such as é takes two bytes, 東 takes three and 👋 takes four. That is why the byte count in the stats can be larger than the number of characters you see. The encoding is correct as long as the other end also treats the bytes as UTF-8, which is the default almost everywhere today.

The output grows by about a third. Three bytes become four characters, so the encoded string is 4/3 of the input, plus a little for padding and line breaks. Base64 is a transport format, not a way to save space.

A worked example

The sample text was ToolsHub4u — free tools, café, 東京 and 👋. With padding on and the standard alphabet, the page reported 49 UTF-8 bytes and 68 Base64 characters, a 39% increase. The first part of the result is shown below.

Encoding and decoding results from the tool
InputSettingResult
Sample sentenceEncode, standard, paddedVG9vbHNIdWI0dSDigJQgZnJlZSB0b29scywgY2Fmw6ksIOadseS6rCBhbmQg8J+Riw==
SGVsbG8sIHdvcmxkIQ==Decode, standardHello, world! (13 bytes, 13 characters)
ÿþEncode, URL-safe, paddedw7_Dvg==

The third row shows the difference between the alphabets. The standard output for those four UTF-8 bytes would contain a /; the URL-safe option writes _ instead. The two strings are not interchangeable unless the decoder knows which alphabet was used.

A longer input produced 180 Base64 characters from 135 bytes, split into three lines of 76, 76 and 28 characters when wrapping was on. The line breaks are formatting only. They are legal in a MIME body but not inside a JSON string, so leave wrapping off when the value goes into JSON.

Check the alphabet before you blame the dataA decode that fails with a message about characters outside the alphabet usually means a URL-safe string was pasted with the standard alphabet selected. Switch the option and try again before editing the value.

Padding, URL-safe output and wrapping

Padding is the = at the end. One = means the last group held two bytes and two = means it held one. The pads let a decoder know how many bits to discard. They are optional in many contexts because the length gives the same information, and the URL-safe variant usually drops them. This page keeps them when Include = padding is ticked, which is the safer default for email and most APIs.

The URL-safe option follows the alphabet in section 5 of RFC 4648: + becomes - and / becomes _. Use it for query strings, filenames and JSON Web Tokens. A + in a query string is often decoded as a space, and a / can be read as a path separator, so the standard alphabet needs percent-encoding in those places.

Wrapping inserts a line break every 76 characters. That number comes from MIME, the email format in RFC 2045, which needed short lines for old mail transport. It is not part of Base64 itself. If a system rejects your value for containing line breaks, turn wrapping off rather than stripping the breaks by hand.

When decoding fails

The decoder is strict about the alphabet, which is the behaviour RFC 4648 recommends. A string containing a space, an @, or a character from the other alphabet stops with That is not valid Base64. Common causes are a copied prefix such as data:image/png;base64,, a missing character at the end, or a value that was URL-safe on the way in.

The page decodes to text, not to files. If the bytes are a PNG, a PDF or another binary format, the result will usually fail because those bytes are not valid UTF-8. Base64 of a binary file needs a decoder that writes a file, not one that writes characters. That is a deliberate boundary, not a bug.

Uploads are read in the browser and are capped at 5 MB. For a larger file, use a command-line tool: base64 -w 0 file.bin on Linux or macOS, or [Convert]::ToBase64String() in PowerShell. Those tools also avoid the copy-and-paste step that tends to add a stray newline.

What Base64 is not

It is not encryption. Anyone with the string and a decoder gets the original bytes back; there is no key. If the text is a password, a token or private data, encode it only after encrypting it, or better, do not put it in a URL at all. The hash generator is for fingerprints, not for hiding data, and hashing is also not encryption.

It is not compression, and it is not a character set. Base64 moves bytes; the question of whether those bytes are UTF-8, Latin-1 or a JPEG is decided before encoding and after decoding. That is why a Base64 string that looks fine can still decode to mojibake: the bytes were never UTF-8 to begin with.

If you are checking a value inside a larger JSON document, paste it into the JSON formatter first. A wrapped Base64 value with real line breaks is not valid JSON, and the formatter will point at the line where the string broke rather than at the encoding.

Questions

Common questions

Short answers about this tool and its limits.

Is Base64 encryption?

No. It is a reversible encoding with no key. Anyone can decode the string and recover the original bytes. Use encryption if the data must stay private, and do not treat Base64 as a way to hide a password or token.

Does it handle emoji and accented letters?

Yes. The text is converted to UTF-8 before encoding, so é, 東京 and 👋 all round-trip correctly. The byte count is larger than the character count because those characters use more than one byte.

Why does the output end with = signs?

The = characters pad the final group to four characters. One pad means the last group held two bytes; two pads mean it held one. Clear Include = padding if the receiving system expects unpadded Base64.

What is URL-safe Base64?

It is the variant in RFC 4648 that uses - and _ instead of + and /, so the value can sit in a URL, filename or token without escaping. The rest of the alphabet is unchanged, and padding may be omitted.

Why does decoding an image fail?

This decoder returns text. The bytes of a PNG or PDF are not valid UTF-8, so the conversion stops with an error. Use a file decoder for binary data, or a command-line Base64 tool that writes the bytes back to a file.

Why is the Base64 string bigger than the input?

Four characters carry three bytes, so the result is about 33% larger before line breaks and padding. The overhead is the price of turning arbitrary bytes into printable text. Base64 never reduces size.

Can I wrap the output at 76 characters?

Yes, with the wrapping option. The line breaks follow the MIME convention and are useful for email. Do not use wrapped output in a JSON string or a URL; keep it on one line there.

Is the text uploaded anywhere?

No. Encoding and decoding happen in the browser. A file you choose is read locally and is limited to 5 MB. There is no account, no server copy and no history, so download or copy the result before leaving the page.