Compare Two Base64 Values – Free

Paste two encoded values to compare Base64 strings by content. The tool decodes both and reports whether the bytes match, so differences in padding, wrapping or alphabet are ignored.

How to use the Compare Base64 tool

  1. Paste one encoded value into the First Base64 value box.
  2. Paste the other into the Second Base64 value box. Select Example to load a padded and an unpadded copy of the same data.
  3. Select Compare to decode both values.
  4. Read the Result box: Match with the shared byte count, or Different with the decoded size of each value.

Why you should compare Base64 strings by bytes

The same data can be written as Base64 in many ways. One system pads with =, another does not. One uses + and /, another - and _. Email and PEM wrap lines at 76 or 64 characters, and browsers put a data URL prefix in front. A plain string comparison or a text diff reports all of these as differences although the content is identical.

This tool removes the representation from the question. It decodes each value to a byte array and compares the two arrays: first the lengths, then every byte in order.

Three comparisons

The first pair differs only in padding and the second only in alphabet, so both match. In the third pair the second value has one extra byte, a trailing line feed, which is what the shell command echo adds unless you pass -n.

First:   SGVsbG8=
Second:  SGVsbG8
Result:  Match · 5 bytes

First:   PDw/Pz8+Pg==
Second:  PDw_Pz8-Pg
Result:  Match · 7 bytes

First:   SGVsbG8=
Second:  SGVsbG8K
Result:  Different · first: 5 bytes, second: 6 bytes

What counts as a match

Only the decoded bytes are compared. Everything else is either ignored or reported as an error.

  • Ignored: = padding, spaces and line breaks, the choice of alphabet, and a data URL prefix including its media type.
  • Not ignored: any byte difference, such as a trailing newline, a byte order mark, or CRLF versus LF line endings.
  • Not ignored: letter case in the Base64 itself. Uppercase and lowercase letters are different characters.
  • Errors: if either value is not valid, the tool shows Enter valid Base64 or Base64URL data instead of Different. It does not say which box is at fault.
  • The report gives sizes only. It does not show the position of the first differing byte.

Typical reasons two encodings differ

When sizes differ by one or two bytes, suspect line endings or a trailing newline. When text was encoded on two systems, suspect the character set: é is the two bytes c3 a9 in UTF-8 and the single byte e9 in Latin-1. JSON that was reformatted, an image that was saved again, and gzip output, which can carry a timestamp in its header, all produce different bytes for content that looks the same.

To find the exact position of a difference, convert both values with Base64 to Hex and diff the dumps.

Frequently asked questions

Are Base64 strings with and without padding equal?

As text, no. As data, yes. The = signs only complete the last group of four characters and carry no bytes, so this tool reports a padded and an unpadded copy of the same value as a match.

Can I compare standard Base64 with Base64URL?

Yes. Each box is decoded on its own, using the URL-safe alphabet when it contains a hyphen or underscore. A standard value and its URL-safe equivalent decode to the same bytes and match.

Does the tool show where the two values differ?

No. It reports Match or Different and the decoded length of each value. For a byte-level view, decode both to hex and compare the dumps side by side in a diff tool.

Why are two encodings of the same text different?

The bytes behind the text differ. The usual suspects are a trailing newline, Windows versus Unix line endings, a byte order mark, or one side using UTF-8 and the other a legacy character set.

Is there a length limit for the values?

The code sets none. Both values are decoded in your browser's memory, so very large inputs are bounded only by what the tab can hold. Nothing is uploaded.

Related tools