Base64 Encode / Decode

Encode text to Base64 or decode Base64 back to text, with UTF-8 and URL-safe Base64URL support.

Back to tools

Encode with - and _ and no padding. Decoding accepts both forms.

How to encode and decode Base64

This tool converts text to Base64 and Base64 back to text on one page. Pick a direction with the Encode to Base64 and Decode Base64 tabs, paste your input, and the result appears as you type. It is useful for building HTTP Basic auth headers, reading the payload of a JWT, checking a value stored in a config file, or embedding a short string in JSON or a data URL.

Text is converted to UTF-8 bytes before encoding, so accented letters, non-Latin scripts and emoji survive the round trip. The decoder accepts both standard Base64 and the URL-safe Base64URL alphabet, ignores whitespace and tolerates missing = padding. Everything runs locally in your browser.

How to use it

  1. Choose Encode to Base64 to turn text into Base64, or Decode Base64 to turn Base64 back into text.
  2. Type or paste into the Plain text box (encode) or the Base64 input box (decode). The output updates automatically after a short pause.
  3. When encoding for a URL, file name or JWT, turn on URL-safe (Base64URL) to get - and _ instead of + and /, with no padding. In decode mode both forms are detected automatically.
  4. Read the result in Base64 output or Decoded text. If the input cannot be decoded, an error message appears in red in the output panel.
  5. Click Copy output, or use Swap input and output to move the result into the input and flip the mode, which is a quick way to confirm the round trip.

Examples

Encoding plain text

The 13 bytes of Hello, world! are not a multiple of 3, so the output ends with == padding.

Plain text
Hello, world!
Base64 output
SGVsbG8sIHdvcmxkIQ==

UTF-8 text with URL-safe (Base64URL) on

With URL-safe (Base64URL) turned on, the last character is _ instead of /. With the switch off, the same input encodes to Q2Fmw6kg4piVIDIwMjY/. The é and the coffee emoji are encoded as their UTF-8 bytes.

Plain text
Café ☕ 2026?
Base64 output
Q2Fmw6kg4piVIDIwMjY_

Decoding a JWT payload

In Decode Base64 mode, the middle segment of a JWT decodes to its JSON claims. It is Base64URL without padding, and the decoder handles both without any switch.

Base64 input
eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkFkYSJ9
Decoded text
{"sub":"1234567890","name":"Ada"}

How Base64 works

Base64 reads the input three bytes (24 bits) at a time and splits them into four 6-bit groups. Each group is written as one character from a 64-character alphabet: A-Z, a-z, 0-9, + and /. When the last group has only one or two bytes, the output is padded with == or = so its length stays a multiple of four.

Because every 3 bytes become 4 characters, Base64 output is about a third larger than the input. It is an encoding, not encryption or compression: anyone can decode it, and it does not hide or shrink anything. Use it to move bytes through systems that only accept text, never to protect secrets.

Standard Base64 and Base64URL

The + and / characters have special meanings in URLs and file paths, so RFC 4648 also defines a URL-safe alphabet that uses - and _ instead. JWTs, many OAuth parameters and some storage keys use this form, usually without = padding.

  • With URL-safe (Base64URL) off, the encoder writes standard Base64 with +, / and padding, as used by MIME email, PEM files, data URLs and HTTP Basic auth.
  • With URL-safe (Base64URL) on, the encoder writes - and _ and removes trailing = characters.
  • The decoder ignores the switch. It converts - and _ back to + and /, adds any missing padding, and decodes, so you can paste either form.

What the decoder accepts and when it fails

Before decoding, all spaces, tabs and line breaks are removed. That means Base64 wrapped at 64 or 76 characters per line, as in PEM blocks and raw email source, decodes without cleanup. You can paste a PEM body, but leave out the -----BEGIN and -----END lines, which are not Base64.

If decoding fails, the output shows Invalid Base64 input, or the decoded bytes are not UTF-8 text. The common causes are characters outside both alphabets (such as @ or .), a truncated string whose length cannot be valid Base64, and Base64 that holds binary data such as an image, a PDF or gzip output. This tool decodes to text, and it refuses byte sequences that are not valid UTF-8 rather than showing garbled characters.

Common uses

Developers run into Base64 in many places. A few quick tasks this page helps with:

  • HTTP Basic auth: encode username:password and send it as Authorization: Basic <value>. This is not a security measure on its own and must only travel over HTTPS.
  • JWTs: decode the header or payload segment to read the claims. Decoding does not verify the signature; use the JWT Decoder to see all parts at once.
  • Config and secrets files: Kubernetes Secrets and many CI systems store values as Base64. Decode to check a value, and remember the stored value is not encrypted.
  • Data URLs and JSON: encode short strings to embed them where only plain ASCII text is allowed.

Privacy

Encoding and decoding run entirely in your browser and nothing is sent to a server. The last input, the selected mode and the switch settings are saved in this browser's local storage so they are still there on your next visit. Click Clear input to remove the saved text, which is worth doing after decoding tokens or credentials on a shared computer.

Related tools

More utilities that pair well with this one.

Frequently asked questions

Common questions about this tool.