Skip to content
MyToolkit.pro

Code & Data

Base64 Encoder / Decoder

Paste plain text or Base64. Valid printable Base64 is decoded automatically; other input is encoded.

Private by design: text is processed only in this browser.

Input

Direction
Variant

Try an example

Result

Input bytes
0
Output bytes
0

How automatic mode works

Input with valid Base64 syntax that decodes to printable text is decoded. Everything else is encoded as UTF-8 text.

How to encode or decode Base64 here

  1. Paste your text or Base64 string into the Text tab. To convert a whole file, switch to the File tab and choose a file of up to 10 MB.
  2. Set the Direction to Auto, Encode or Decode. The section below explains when Auto guesses wrong.
  3. Choose the Variant. Standard Base64 uses +, / and = padding. Base64URL uses - and _ and has no padding.
  4. The result updates as you type. If you change the direction or variant, the tool converts the input again straight away.
  5. Click Copy result to copy the output. After a decode in the File tab, "Download decoded file" saves the raw bytes as decoded-file.bin.

The Input bytes and Output bytes counters count UTF-8 bytes, not characters. For example, zażółć is 6 characters but 10 bytes, because each Polish letter takes two bytes.

Base64 encode and decode examples

Input Direction / Variant Output
Hello World! Auto, Standard SGVsbG8gV29ybGQh
zażółć Encode, Standard emHFvMOzxYLEhw==
zażółć Encode, Base64URL emHFvMOzxYLEhw
<<??>> Encode, Standard PDw/Pz4+
<<??>> Encode, Base64URL PDw_Pz4-
user:pass Encode, Standard dXNlcjpwYXNz

The two <<??>> rows show how the variants differ. The same bytes give / and + in standard Base64 but _ and - in Base64URL. That lets a Base64URL string go into a URL or file name without percent-encoding.

You don't have to clean up Base64 before you decode it. Spaces and line breaks are ignored, so you can paste wrapped output from MIME email attachments, PEM blocks or terminal logs as it is:

SGVs bG8g
V29y bGQh   →   Hello World!

Missing = padding is also accepted. SGVsbG8 decodes to Hello, the same as SGVsbG8=.

When auto-detection picks the wrong direction

Auto decodes the input only when it is valid Base64 for the selected variant and the decoded bytes are valid UTF-8 text. Everything else is encoded. This can surprise you in a few ways:

  • Short words: TWFu is valid Base64 for Man, and Zm9v decodes to foo, so Auto decodes both. Words like test or abcd don't decode to valid text, so they get encoded (dGVzdA==, YWJjZA==). To encode TWFu itself, choose Encode and you get VFdGdQ==.
  • Wrong variant: with Standard Base64 selected, Auto treats PDw_Pz4- as plain text and encodes it to UER3X1B6NC0=, because - and _ aren't in the standard alphabet. Switch to Base64URL and the same input decodes to <<??>>.
  • Damaged input: Auto encodes a malformed string instead of reporting a problem. For example, SGVsbG9= becomes U0dWc2JHOT0=.

If you know the input is Base64, select Decode. The tool then shows "Enter valid Base64 for the selected variant." instead of guessing. That covers a mismatched alphabet and strings a correct encoder could never produce, such as SGVsbG9=, whose last character carries leftover bits. You can use this to spot a truncated or hand-edited value.

Text, binary files and the 10 MB limit

Text input is encoded as UTF-8, so accented letters, emoji and non-Latin scripts come back unchanged after decoding. With Decode selected, if the decoded bytes aren't valid UTF-8 (an image, a ZIP or a compressed payload), the text view shows an error instead of garbled characters. In Auto, the same input counts as text and is encoded. A PNG header such as iVBORw0KGgo= turns into aVZCT1J3MEtHZ289.

To recover binary data, save the Base64 string to a .txt file. Upload it in the File tab with Decode selected, then use "Download decoded file".

In the File tab with Encode selected, any file up to 10 MB becomes a single Base64 string with no line breaks. Larger files are rejected before they are read. Everything runs locally in the browser, so pasted tokens and config secrets are not sent anywhere. Base64 is an encoding, not encryption: anyone can decode it.

  • A JWT is made of Base64URL segments, and its signature isn't text. The JWT Decoder splits a token into its header and payload and shows them as formatted JSON.
  • To make text safe for a query string, use the URL Encoder / Decoder. Percent-encoding is a different scheme from Base64URL.
  • To embed a picture in CSS or HTML, Image to Base64 produces a ready data: URI with the correct MIME type.

Both alphabets and the padding rules are defined in RFC 4648.

Frequently asked questions

Why does Base64 output end with = or ==?

Base64 encodes 3 bytes at a time into 4 characters. When the input length isn't a multiple of 3, one or two `=` characters fill out the last group. Base64URL usually leaves the padding out.

Why is the Base64 string longer than the original text?

Every 3 bytes become 4 characters, so the output is about 33% larger, plus any padding. For example, the 12-byte `Hello World!` becomes 16 characters.

How do I decode Base64 on the command line?

On Linux and recent macOS, run `base64 --decode input.txt > output.bin`. On Windows, `certutil -decode input.txt output.bin` does the same.

Is Base64 used in HTTP Basic Auth?

Yes. The client encodes `user:pass` as Base64 and sends it as `Authorization: Basic dXNlcjpwYXNz`. Anyone can decode that header, so Basic Auth is only safe over HTTPS.

All in Code & Data

URL Encoder / Decoder

Percent-encode or decode URL text instantly and privately in your browser.

Code & Data In your browser

Morse Code Translator

Translate text to Morse code and back in your browser. Choose the direction, get instant output with correct word spacing. Nothing is uploaded.

Code & Data In your browser

Image to Base64

Convert an image to a Base64 data URL locally in your browser, with preview, validation and one-click copy.

Image Tools In your browser

HTML Entity Encoder

Encode text to HTML entities or decode entities back to text in your browser. Escape <, >, &, quotes safely, or reverse named, decimal and hex entities. Nothing is uploaded.

Code & Data In your browser

Text to Binary

Convert text to binary and binary back to text in your browser. Pick the direction, get clean space-separated bytes. Nothing is uploaded.

Code & Data In your browser

Caesar cipher (ROT13)

Encode or decode text with a Caesar cipher — each letter is rotated forward through the alphabet by a fixed amount. A shift of 13 is ROT13, its own inverse. Digits, spaces and punctuation are left as they are.

Code & Data In your browser

What do you need?

Swipe up for the next one