Skip to content

isBase64 ​

Checks if a string is Base64 encoded.

Syntax ​

typescript
isBase64(value: string): boolean

Parameters ​

NameTypeDescription
valuestringThe string to be checked

Returns ​

TypeDescription
booleanReturns true if the string is in Base64 format, otherwise false

Example ​

typescript
isBase64("U29tZSBkYWRv"); // true
isBase64("12345"); // false
isBase64(12345); // throws TypeError

Notes ​

  • Throws a TypeError if the value is not a string.
  • Accepts valid Base64 strings, including padding with =.

References ​

Released under the MIT License.