Normalize Base64 to One Format – Free

Paste Base64 in any valid shape and normalize Base64 into one of two canonical forms: the standard alphabet with padding, or the URL-safe alphabet without it.

How to use the Normalize Base64 tool

  1. Paste the value into the Base64 or Base64 data URL box, or select Example.
  2. Under Output format, choose Standard, padded or URL-safe, unpadded.
  3. Select Normalize to decode and re-encode the value.
  4. Select Copy to take the rewritten value from the Result box.

What it means to normalize Base64

The same bytes can arrive wrapped across lines, with or without = signs, in either alphabet, or inside a data URL. Normalizing means decoding the value to bytes and encoding those bytes again under one fixed set of rules. Every representation of the same data then collapses to a single string.

That single string is what you want for database keys, cache lookups, deduplication and equality checks in code, where two spellings of one value would otherwise count as two values.

A worked example

The input below is URL-safe, unpadded and split over three lines. Both output formats describe the same seven bytes.

Input:
  PDw_
  Pz8-
  Pg

Standard, padded:    PDw/Pz8+Pg==
URL-safe, unpadded:  PDw_Pz8-Pg

The two output formats

Standard, padded follows RFC 4648 section 4: + and / for the last two alphabet positions, and = signs until the length is a multiple of four. Email bodies, PEM files, HTTP Basic credentials and the default decoder in most languages expect this form.

URL-safe, unpadded follows section 5 with the padding left off: - and _ replace + and /, and no = appears. JSON Web Tokens, URL parameters and file names use it. The other two combinations, standard without padding and URL-safe with padding, are not offered. If you need one, add or remove the = signs yourself: a string needs enough of them to reach a multiple of four characters.

What normalization removes and what it refuses

Output is always a single line. Whitespace and line wrapping are not kept, and a data URL prefix is dropped, not re-added.

The input must already be valid. A string that mixes the two alphabets, has the wrong number of = signs, or has stray bits set in its final character stops with Enter valid Base64 or Base64URL data. For those cases use Repair malformed Base64, which is lenient about such faults but only writes the standard form.

Frequently asked questions

How do I convert Base64 to Base64URL?

Paste the standard string, set Output format to URL-safe, unpadded and select Normalize. Each + becomes -, each / becomes _ and trailing = signs are removed. The bytes it represents stay the same.

How do I add missing padding to a Base64URL string?

Choose Standard, padded. The tool decodes the unpadded value and writes it back with = signs and the standard alphabet, which is the form that strict decoders such as Python's b64decode accept.

Does normalizing change the decoded data?

No. Only the spelling changes. The tool decodes to bytes and re-encodes those same bytes, so decoding the input and decoding the output give identical results.

Why does a string with both + and _ fail?

No single alphabet contains both characters, so the value is not valid in either variant and cannot be decoded safely. Find out how the string was produced, or try the repair tool, which maps both sets to standard.

Can I keep the line breaks or the data: prefix?

No. The result is the bare Base64 on one line. Wrap it again or put the prefix back afterwards if the destination requires either.

Related tools