JWT token validation issue

As an example, here I mess with the end of a base64 encoded string. It’s only when I replace the last four character that the original string gets mangled:

#Encode the string
$ base64 -i -
The green leg dyed the apple blue in the sky.
VGhlIGdyZWVuIGxlZyBkeWVkIHRoZSBhcHBsZSBibHVlIGluIHRoZSBza3kuCg==

#Decode the string
$ base64 -d -
VGhlIGdyZWVuIGxlZyBkeWVkIHRoZSBhcHBsZSBibHVlIGluIHRoZSBza3kuCg
The green leg dyed the apple blue in the sky.%                                                      

#Change last char and decode
$ base64 -d -
VGhlIGdyZWVuIGxlZyBkeWVkIHRoZSBhcHBsZSBibHVlIGluIHRoZSBza3kuCi
The green leg dyed the apple blue in the sky.%                                                      

#Change last 3 chars and decode
$ base64 -d -
VGhlIGdyZWVuIGxlZyBkeWVkIHRoZSBhcHBsZSBibHVlIGluIHRoZSBza3kaaa
The green leg dyed the apple blue in the sky%                                                       

#Change last four chars and decode
$ base64 -d -
VGhlIGdyZWVuIGxlZyBkeWVkIHRoZSBhcHBsZSBibHVlIGluIHRoZSBza3aaaa
The green leg dyed the apple blue in the skv�%                                                      
$