Base64
Encode UTF-8 text as Base64, or decode Base64 to UTF-8 text.
Base64 example: encoding and decoding
Base64 takes 3 bytes of input at a time and writes them as 4 characters. The text
Hello, World! is 13 bytes long and encodes to 20 characters:
Hello, World! → SGVsbG8sIFdvcmxkIQ==
The two = signs are padding. 13 bytes leave 1 byte over after four full groups of 3, and a
group with 1 byte is written as 2 characters plus ==. The three cases:
Man(3 bytes) →TWFu, no paddingMa(2 bytes) →TWE=, one padding characterM(1 byte) →TQ==, two padding characters
The output is always one third longer than the input: 3 MB of data become 4 MB of Base64.
Why a Base64 string fails to decode
- Missing padding. A string whose length is not a multiple of 4 is rejected with
"Incorrect padding". Tokens and URLs often drop the trailing
=; append=until the length is a multiple of 4. - URL-safe alphabet. Strings that contain
-or_use the URL-safe variant. Replace-with+and_with/before decoding here; with them the decoder reports an error or returns wrong text. - Binary content. The decoder shows the bytes as UTF-8 text. A decoded image, archive or key is not text and appears as replacement characters (�). The Base64 itself was valid.
- Line breaks. Email (MIME) wraps Base64 at 76 characters and PEM certificates at 64. The line breaks are ignored on decoding.
Related tools
Monitor Base64 automatically
Encode UTF-8 text as Base64, or decode Base64 to UTF-8 text. NetTests can run this check on a schedule, preserve historical results, compare changes over time, and alert you the moment something breaks.
Start monitoring free → See all monitoring productsFrequently Asked Questions
What is Base64 encoding?
Base64 is an encoding scheme that converts binary data into a string of printable ASCII characters using 64 symbols (A–Z, a–z, 0–9, +, /). It is not encryption — the data is trivially reversible. It's used wherever binary data must be transmitted over a text-only channel: email attachments (MIME), data URIs in HTML/CSS, and JWTs.
When should I use Base64?
Use Base64 when you need to embed binary data (images, certificates, binary files) inside a text format like JSON, XML, or HTML. For example, data:image/png;base64,iVBOR... embeds an image directly in a stylesheet. Do not use Base64 to 'secure' data — it provides no confidentiality.
What is the difference between standard and URL-safe Base64?
Standard Base64 uses + and / which have special meaning in URLs. URL-safe Base64 (RFC 4648) replaces them with - and _ so the result can be used directly in URLs and filenames without percent-encoding. JWTs use URL-safe Base64 without padding (=). This tool uses standard Base64.
Why does a Base64 string end with = or ==?
Base64 encodes 3 bytes at a time into 4 characters. If the input isn't a multiple of 3 bytes, padding characters (=) fill the last group to maintain the 4-character block size. One = means 2 leftover input bytes; == means 1 leftover byte.