Base64 Encoder & Decoder

Encode and decode Base64 online. Convert text to Base64 or decode Base64 back to readable text, with a URL-safe mode for tokens, filenames, and URLs.

Copied
Input0 B
Output0 B

What is Base64 encoding?

Base64 is a binary-to-text encoding, defined in RFC 4648, that represents any sequence of bytes using 64 printable ASCII characters (A–Z, a–z, 0–9, + and /), with = used for padding. It does not compress or encrypt anything — it re-encodes bytes into a form that survives systems built for plain text, such as email (MIME), JSON payloads, HTTP headers and configuration files.

Every 3 bytes of input become 4 Base64 characters, so encoded output is about 33% larger than the original. When the input length is not a multiple of 3, the last group is padded with one or two = signs. Decoding reverses the process exactly, with no loss. For a longer walk-through, read Base64 explained.

How to use the Base64 encoder and decoder

  1. Type or paste text into the Input pane.
  2. Tick URL-safe (- _, no padding) if the result is going into a URL, filename or token.
  3. Click Encode to turn the text into Base64, or Decode to turn Base64 back into text.
  4. Use Copy, or Download to save the result as base64-result.txt. Clear empties both panes.

Options and behaviour explained

This page works on text. It has no file upload, and Decode only shows output that is valid UTF-8 text. To turn an image into Base64 or a data URI, use the Image to Base64 tool.

Examples

InputBase64 (standard)Base64 (URL-safe)
Hello, World!SGVsbG8sIFdvcmxkIQ==SGVsbG8sIFdvcmxkIQ
user:pass123dXNlcjpwYXNzMTIzdXNlcjpwYXNzMTIz
{"a":1}eyJhIjoxfQ==eyJhIjoxfQ
?>?Pz4/Pz4_
caféY2Fmw6k=Y2Fmw6k
👍8J+RjQ==8J-RjQ

The padding pattern is easy to see with short inputs: Man (3 bytes) encodes to TWFu with no padding, Ma to TWE= and M to TQ==. The ?>? row shows why URL-safe mode exists: the standard alphabet produces a /, which would break a URL path.

Common uses of Base64

Decoding a data URL such as data:text/html;charset=utf-8;base64,

A data URL carries a whole file inside the address itself: data:, the media type (for example text/html;charset=utf-8 or image/png), ;base64, and then the Base64-encoded content. You meet them in HTML and CSS, in links copied out of developer tools, and in phishing emails that hide a page inside a link. Paste the complete data URL above and press Decode: the prefix is removed and the content after the comma is decoded, so data:text/html;charset=utf-8;base64,PGgxPkhlbGxvPC9oMT4= becomes <h1>Hello</h1>. The decoded HTML is shown as text and never opened or run, which also makes this a safe way to see what a suspicious data link contains.

To build a data URL, encode your HTML or text here and put data:text/html;charset=utf-8;base64, in front of the result. For images, the image to Base64 converter writes the complete data URL for you. Data URLs whose content is percent-encoded rather than Base64 (no ;base64 in the prefix) are URL-encoded text: decode those with the URL encoder and decoder.

Common errors and how to fix them

Failed decodes are reported above the panes and in the Output pane, starting with Invalid Base64 input:. The rest of the message comes from your browser, so its wording differs between Chrome, Firefox and Safari.

SymptomCauseFix
Error about an invalid or incorrectly encoded characterThe input contains characters outside the Base64 alphabet, such as $, quotes or surrounding JSON.Paste only the Base64 text. A data:...;base64, prefix is fine: Decode removes it for you.
Error about data that is not valid UTF-8The Base64 is valid but encodes binary data (an image, a ZIP, a compressed or encrypted value), not text.Decode it with a tool or library that writes bytes to a file instead of showing text.
Error on a value of 1, 5, 9… charactersA length that leaves one character over can never be valid Base64; the string was probably cut off.Copy the full value again.
Encoded result differs from another toolThe other tool used URL-safe mode, kept or dropped padding, or encoded text in a different character set.Match the URL-safe setting; this tool always encodes text as UTF-8.

Frequently asked questions

Is Base64 encoding the same as encryption?

No. Base64 is a reversible encoding, not encryption. Anyone can decode a Base64 string without a key or password, so never rely on it to protect passwords, tokens or personal data.

What is URL-safe Base64?

Standard Base64 uses +, / and =, which have special meanings in URLs and are awkward in filenames. URL-safe Base64 (Base64url) swaps + for - and / for _, and usually omits padding. JWTs use it for all three segments.

Why is my Base64 output bigger than the input?

Each Base64 character carries 6 bits, so 3 bytes need 4 characters — about a third more, plus up to two padding characters. Non-ASCII text grows further because it takes 2–4 bytes per character in UTF-8 before encoding.

Should I use Base64 or hexadecimal?

Both turn bytes into text. Hexadecimal uses two characters per byte, so it doubles the size but is easy to read byte by byte — Hi! is 486921. Base64 uses four characters per three bytes (SGkh), so it is more compact and is the usual choice for data URIs, email and tokens. Hashes and checksums are more often shown in hex.

Do I need the = padding at the end?

Padding makes the length a multiple of 4, but the data can be decoded without it. This tool adds missing padding automatically when decoding. Some other decoders are strict, so keep the padding when the receiving system expects standard Base64.

Why does my decoded text look wrong or fail?

Usually the input is incomplete, has extra characters around it, or encodes binary data rather than text. This tool reads decoded bytes as UTF-8 and reports an error rather than showing garbled characters when they are not valid UTF-8.

Is my data sent to a server?

No. Encoding and decoding use your browser's built-in functions, and the text you enter is not sent anywhere by the tool.

Guides

Related tools