Base64 Encode / Decode

Encode text to Base64 or decode Base64 strings instantly.

TEXT INPUT0 chars

When a Base64 encoder is the right tool

Base64 is a way to write binary data as text, using a 64-character alphabet that survives in places that expect ASCII: a data URI, an email attachment, a JSON string, or a configuration value that cannot hold raw bytes. This page is for the everyday case where the thing you have is a string. You paste the text, and a standard Base64 encoding appears — or you paste Base64 and get the decoded text back.

It is an encoding, not encryption. Anyone who can see the output can decode it. If you have an image or another file rather than a string, use Image to Base64. If a system wants Base32, percent-encoding, or a hash, those are different tools: Base32, URL Encoder, and the Hash Generator.

Use cases

Turning a string into Base64 for an API or a config file

Some APIs and environment variables ask for a Base64 value, such as a basic-auth pair or a small JSON blob that has to travel as a single token. Paste the text in Encode mode and copy the output. The conversion updates as you type, so you can adjust the input and watch the encoding change.

Reading a Base64 value you were sent

Tokens, data URIs (after you strip the data:... prefix), and config values often arrive already encoded. Switch to Decode, paste the string, and read the text. If the alphabet is URL-safe or the paste includes line breaks, clean it first, or the decoder will report an invalid Base64 string.

Checking that Unicode survives the round trip

This page encodes text as UTF-8 before it applies Base64, so characters outside ASCII are not silently corrupted the way a naïve btoa call would be. After a decode, you should see the same text you started with. Use as Input is a quick way to flip the direction and confirm that.

How encoding and decoding work

Encode and Decode are two modes, chosen with the tabs at the top. In Encode mode, the input is turned into UTF-8 bytes with TextEncoder, those bytes are converted to a binary string, and btoa produces standard Base64 (the A–Z, a–z, 0–9, +, / alphabet, with = padding as needed). In Decode mode, atob reverses the Base64, and TextDecoder reads the bytes as UTF-8 text. An empty input clears the output. An invalid Base64 string shows an error and no output.

Switching tabs resets the fields. Use as Input does not: it copies the current output into the input, switches direction, and runs the conversion. The character count is the length of the input text, not of the encoded form. The output pane wraps long strings so you can copy them in one piece.

Example — ASCII text and its standard Base64
hello

aGVsbG8=

hello encodes to aGVsbG8=. Decoding that string returns hello. This is the usual textbook example, and it is a good first check that the page is in the mode you expect.

Example — UTF-8 text, not a naïve Latin-1 encoding
café

Y2Fmw6k=

The é in café is the UTF-8 bytes c3 a9, so the Base64 form is Y2Fmw6k=, not the shorter string you would get by treating the character as a single Latin-1 byte. If another tool disagrees with this output, it is often because that tool is not using UTF-8.

What this tool does not do

It does not accept a file upload, produce a data: URI, or encode raw binary that you cannot paste as text. It does not use the URL-safe alphabet, strip whitespace for you, or treat Base64 as encryption. Nothing is sent to a server. For files and images, use Image to Base64 instead.

How to use Base64 Encode / Decode

  1. Choose Encode to turn text into Base64, or Decode to turn Base64 back into text. Switching tabs clears the fields.
  2. Paste or type in the input pane. The output updates as you type.
  3. Copy the result from the output pane when it looks right.
  4. Use as Input if you want to flip the direction and run the conversion on the current output. Use Clear to start over.

Frequently asked questions

Does encoding happen as I type?

Yes. There is no separate Encode or Decode button for the conversion itself. The two tabs choose the direction, and the output updates on each change to the input. Switching tabs clears both fields. Use as Input (Swap) takes the current output, flips the direction, and runs the conversion again.

Does this tool handle Unicode, or only ASCII?

It encodes and decodes text as UTF-8. Characters outside ASCII, such as café or non-Latin scripts, are first turned into UTF-8 bytes and then into standard Base64. Decoding runs the same steps in reverse with the browser's UTF-8 decoder.

Is this the same as URL-safe Base64?

No. The output uses the standard Base64 alphabet (A–Z, a–z, 0–9, +, /) with = padding, as produced by the browser's btoa function after a UTF-8 conversion. URL-safe Base64, which uses - and _ and often drops padding, is a different alphabet and will usually fail to decode here unless you convert it first.

Can I encode an image or a file?

Not on this page. The input is a text area, so it is meant for strings. To turn an image or another file into a data URI or a Base64 string, use the Image to Base64 page, which accepts a file.

Why does a Base64 string fail to decode?

The decoder uses the browser's atob function, then interprets the bytes as UTF-8 text. Strings with spaces or line breaks, URL-safe characters, or other characters outside the standard alphabet often fail, and you will see an invalid Base64 error. Strip whitespace or convert the alphabet, then paste again. A valid Base64 string that is not UTF-8 text may also decode as garbled characters.

Is my text sent to a server?

No. Encoding and decoding run in your browser. Closing the tab discards what you pasted. Do not paste tokens, passwords, or other secrets if you would not be comfortable with them sitting in memory on this device.

Is there a size limit?

There is no server-imposed limit, because nothing is uploaded. Short strings are instant. Very large pastes can make the tab feel slow or hit a browser limit; in that case, use a local tool.

Related tools and guides

References

  • RFC 4648 defines the Base64 and Base32 alphabets, including the URL-safe Base64 variant. This page implements the standard Base64 alphabet via the browser's btoa and atob functions, after a UTF-8 conversion.
  • btoa and TextEncoder are the Web APIs used here. btoa alone only accepts binary strings; the UTF-8 step is what makes Unicode text work.
  • Base64 is an encoding, not encryption. Anyone can decode the output. Do not treat it as a way to hide a secret.