Base64 Encode and Decode

Encode and decode Base64

About Base64 Encode and Decode

Base64 Encode and Decode turns text into Base64 and Base64 back into text. Your text is first written as UTF-8 bytes, so accented letters, other scripts, and emoji come back exactly as typed, and the result matches what Python's base64 module or Node.js Buffer produce for the same text. Check the URL-safe option to get the - and _ alphabet without = padding used in JWTs and URL parameters. Decode reads both alphabets, missing padding, and wrapped lines. When the decoded bytes are not UTF-8 text, the tool gives their count instead of garbled characters. Your browser's TextEncoder, btoa, and atob do the work. It takes pasted text only; to encode a file, use File to Base64.

Example

The text below encoded twice: once as is, once with the URL-safe box checked. Decode turns either result back into the same text.

Text

Café ☕ 1>0?

Encode

Q2Fmw6kg4piVIDE+MD8=

URL-safe checked:
Q2Fmw6kg4piVIDE-MD8

How to encode or decode Base64 text

  1. 1Paste the text to encode, or the Base64 to decode, into the box.
  2. 2For a URL, a file name, or a JWT, check "URL-safe Base64 when encoding" before encoding.
  3. 3Click "Encode" or "Decode"; invalid Base64 gets a message that names the problem.
  4. 4Copy the Base64 or the decoded text with "Copy"; "Download" writes base64.txt, a name it keeps even for decoded text.

Formats and limits

Input
Any text for Encode; for Decode, standard or URL-safe Base64, with or without = padding, spaces and line breaks ignored
Output
Standard Base64, URL-safe Base64 without padding, or the decoded UTF-8 text; download as base64.txt
Text length
The tool sets no length cap. Above 1,000,000 characters the input box shows only the beginning, and the tool still works on all of it
Not handled
Files (see File to Base64) and binary results, which are reported as a byte count

Where your text is processed

Encoding and decoding run in this page with your browser's TextEncoder, btoa, and atob, so the text you paste is not sent anywhere and nothing is stored. If an error message appears or the browser refuses a copy, we receive that error, the tool's name, and your browser's name and version, never the text you pasted, so that we can fix problems.

Frequently asked questions

Is Base64 encryption?

No. Base64 only rewrites bytes with 64 printable characters, and anyone can decode it with this page or one line of code. Do not use it to hide passwords, keys, or personal data; use real encryption for that.

How much longer is Base64 than my text?

About a third longer than the UTF-8 bytes it encodes, since every three bytes become four characters. Most accented letters take two bytes and most emoji four, so text outside plain English grows more than its letter count suggests.

What does URL-safe Base64 change?

It writes - and _ instead of + and /, and drops the = padding, which is the form JWTs and URL parameters use. The box only affects Encode; Decode reads both alphabets, with or without padding, without any setting.

Can Decode show an image or a ZIP stored in Base64?

No. When the decoded bytes are not valid UTF-8 text, as with an image, a PDF, or a ZIP, the tool gives their size in bytes instead of printing unreadable characters. It does not rebuild the file.

Can I encode a file or an image?

No, this page encodes text. File to Base64 reads any file and gives a data URL or raw Base64, and Image to Base64 can also write an HTML img tag or a CSS background-image line for a picture.

Tips and tricks

  • ✓To read one part of a JWT, paste it here and click "Decode": URL-safe input without padding is accepted as it is.
  • ✓A message saying the length is impossible usually means a character was lost when the Base64 was copied.