Skip to main content
@spa-tools/utilities

looksLikeBase64()

The looksLikeBase64() function checks if a string looks to be a base64 encoded string.

Usage

import { looksLikeBase64 } from '@spa-tools/utilities';

const isBase64 = looksLikeBase64('SGVsbG8gd29ybGQh'); // true
console.log(isBase64);
// --> true

const isNotBase64 = looksLikeBase64('Hello World');
console.log(isNotBase64);
// --> false

Arguments

NameTypeRequired?Description
strstringyesThe string to check

Returns

boolean - If string passes base64 regex test then returns true else returns false.