Skip to content
DayUtils

Base64 Encoder and Decoder – Text to Base64 and Back

Encode any text to Base64, or decode Base64 back into readable text. The tool fully supports UTF-8, so accented letters, non-Latin scripts and emoji survive the round trip, and it can produce URL-safe Base64URL for tokens and web addresses.

Loading tool…

How to use the Base64 encoder and decoder

  1. Choose Encode or Decode.
  2. Type or paste your text or Base64 into the input box.
  3. For encoding, tick URL-safe if you need Base64URL.
  4. Copy the result, or press Use as input to reverse it.

When encoding, the status line shows how many bytes your text took up and how long the Base64 is.

How Base64 works

Your text is first turned into bytes using UTF-8. The bytes are then taken three at a time (24 bits) and split into four groups of 6 bits. Each 6-bit number, from 0 to 63, is replaced by one character from the Base64 alphabet. If the last group has fewer than three bytes, = signs pad the result to a multiple of four characters.

Encoded length = 4 × ⌈bytes ÷ 3⌉

Worked example

“Man” is three bytes: 77, 97, 110. In binary: 01001101 01100001 01101110. Split into 6-bit groups: 010011 010110 000101 101110 = 19, 22, 5, 46 = TWFu.

“Hello” (5 bytes) encodes to SGVsbG8= — the = shows the last group was one byte short.

Why UTF-8 matters

Older tools encode only the first 256 characters correctly and garble everything else. This tool converts text to UTF-8 bytes first, so “Héllo wörld ✓”, Hindi, Arabic, Chinese and emoji all encode and decode correctly. When decoding, it checks that the bytes form valid UTF-8 and warns you if they don’t.

Where Base64 is used

  • Email attachments (MIME) are sent as Base64.
  • Data URIs embed small images directly in HTML and CSS.
  • JSON Web Tokens use Base64URL for their header and payload.
  • HTTP Basic authentication sends username:password in Base64 — which is why it must only be used over HTTPS.
  • APIs often transfer files as Base64 strings inside JSON.
  • Configuration, such as Kubernetes secrets, stores values in Base64.

Padding and line breaks

The = signs at the end of Base64 text are padding. Some systems drop them; this decoder adds them back automatically, so both forms work. Older email systems also split Base64 into lines of 76 characters — the decoder ignores spaces and line breaks, so you can paste wrapped text directly. If decoding still fails, check that the text hasn’t been cut short when it was copied, because a missing character changes every byte that follows it.

Security note

Base64 hides nothing. If you find credentials or personal data in Base64, treat them exactly as if they were plain text. To protect data, use real encryption; to check data integrity, use a hash from the hash generator.

For URLs, use the URL encoder; to read a token, the JWT decoder. All encoding happens in your browser.

Frequently asked questions

What is Base64?

A way of writing any data using only 64 safe characters: A–Z, a–z, 0–9, + and /, with = for padding. It lets binary data travel through systems built for text, such as email, JSON and URLs.

Is Base64 encryption?

No. Anyone can decode it instantly. It is an encoding, not a way to keep secrets — never use it to hide passwords or private data.

What is Base64URL?

A URL-safe variant that uses - and _ instead of + and /, and usually drops the = padding. It is used in JSON Web Tokens and in data placed inside URLs.

Why is the encoded text longer?

Base64 turns every 3 bytes into 4 characters, so the result is about 33% larger than the original.

Why does decoding show an error?

Either the input contains characters that aren’t valid Base64, or it decodes to binary data — such as an image or a zip file — rather than readable text.

How do I encode an image to Base64?

Use the image to Base64 tool, which reads the image file in your browser and produces a data URI ready for HTML or CSS.

Last updated: