Base64 Encode / Decode

How do I encode Base64?

How it is calculated

Base64 rewrites bytes using 64 safe characters: A to Z, a to z, 0 to 9, plus and slash, with equals signs as padding. Encoding takes your text as bytes, groups them in threes (24 bits), and splits each group into four 6-bit values, each mapped to one character. If the last group is short, one or two = are added. Output is about 4 × ⌈n ÷ 3⌉ characters for n input bytes, roughly one third larger. Decode mode reverses this in strict mode; if the input is not valid Base64, the tool shows an invalid-input message instead of text. Base64 is an encoding, not encryption: anyone can reverse it.

Worked example

Encode the text Hello, World! in encode mode. It is 13 bytes, which is four full groups of three plus one leftover byte. The first twelve bytes give 16 characters, SGVsbG8sIFdvcmxk. The last byte, the exclamation mark, produces IQ and two = padding signs to fill the final group of four. The tool outputs SGVsbG8sIFdvcmxkIQ==, 20 characters. Switching to decode mode and pasting that string returns the original text.

Try this example →

Common mistakes

  • Treating Base64 as encryption. It hides nothing; never use it to protect passwords or secrets.
  • Pasting a string that has line breaks, spaces or a missing padding sign into decode mode. Decoding is strict and will report invalid input.
  • Decoding with the wrong mode selected. Running encode on an already encoded string produces a longer, double-encoded string.
  • Decoding the URL-safe variant, which uses - and _ instead of + and /. Swap those characters first.
  • Expecting readable output when decoding binary data such as an image. The bytes are not text and will look like garbage.

About this calculator

This tool encodes plain text into Base64, a scheme that represents binary data using only 64 printable ASCII characters (A–Z, a–z, 0–9, + and /), or decodes a Base64 string back into its original readable text. Base64 does not compress or encrypt data — it purely re-encodes it into a format guaranteed to survive systems that only handle text safely.

It is used throughout web development and networking wherever binary-safe data needs to travel through text-only channels: embedding small images directly inside CSS or HTML, encoding attachments in emails, packing authentication tokens and credentials into HTTP headers and URLs, and storing binary blobs inside JSON or XML payloads. Developers reach for a quick Base64 encoder or decoder constantly when debugging API requests, inspecting JWT tokens, or preparing data for an interface that can only accept plain text.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    Base64 is an encoding, not encryption: anyone can reverse it, so never use it to hide a password or token. Text is encoded as UTF-8 bytes, which means accented letters and emoji give longer output than plain ASCII. Decoding is strict, so URL-safe variants that use - and _ in place of + and / will show as invalid until you swap them back. If a decode succeeds but the text looks garbled, the source was probably binary. What are you decoding?

Popular calculators

All Calculators