Skip to content

isBase64URL

Checks if a string is Base64URL encoded.

Syntax

typescript
isBase64URL(value: string): boolean

Parameters

NameTypeDescription
valuestringThe string to be checked

Returns

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

Example

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

Notes

  • Throws a TypeError if the value is not a string.
  • Base64URL uses the characters A-Z, a-z, 0-9, _, and -.

References

Released under the MIT License.