I\'m using the window.atob(\'string\')
function to decode a string from base64 to a string. Now I wonder, is there any way to check that \'string\' is actually
This method attempts to decode then encode and compare to the original. Could also be combined with the other answers for environments that throw on parsing errors. Its also possible to have a string that looks like valid base64 from a regex point of view but is not actual base64.
if(btoa(atob(str))==str){
//...
}