Skip to content
uencoder
TUTORIAL

How to Base64 Decode Text

Learn to reverse a Base64 string back to its original form, including how to handle padding and invalid characters.

Problem

You have received a Base64-encoded string and need to recover the original plain text or binary data.

Prerequisites

  • Understanding of Base64 alphabet
  • Ability to recognize padding characters

Steps

  1. 1. Inspect the Base64 string

    Confirm the string only contains valid Base64 characters (A-Z, a-z, 0-9, +, /) and optional = padding. Remove any whitespace or line breaks that may have been inserted for readability.

    Input
    SGVsbG8sIFdvcmxkIQ==
    Output
    clean string
  2. 2. Decode the string

    Pass the cleaned string to a Base64 decoder. The decoder maps each character back to a 6-bit value, concatenates the bits, and splits them into 8-bit bytes.

    Input
    SGVsbG8sIFdvcmxkIQ==
    Output
    Hello, World!
  3. 3. Interpret the result

    If the original data was text, display it as text using the correct character set. If it was binary, save it as a file or inspect the bytes. A garbled result usually means the wrong charset was assumed.

    Input
    SGVsbG8sIFdvcmxkIQ==
    Output
    Hello, World!

Expected result

The original text or binary data, identical to what was encoded before.

Common errors

Decoding fails with 'invalid length'
The string is not a multiple of 4. Add the missing = padding characters or re-encode the source.
Output is garbled or shows replacement characters
The original data was binary or used a different character set. Decode as bytes and inspect the raw output.

Troubleshooting

  • Strip all whitespace before decoding.
  • If the string came from a URL, replace - with + and _ with / (URL-safe Base64) first.

Security limits

  • Decoding Base64 reveals the original data instantly. Do not treat Base64 as a security barrier.

Related tools

Related glossary

Related tasks

Ready to run it?

References