Skip to main content

Function: decodeStrictBase64()

decodeStrictBase64(value): Buffer<ArrayBufferLike> | null

Decodes standard (RFC 4648) base64. Whitespace is ignored, so line-wrapped output and a trailing newline decode fine. Returns null for anything that is not the canonical encoding of the bytes it decodes to: characters outside the standard alphabet (quotes, URL-safe - and _), missing or misplaced = padding, a truncated value. Unlike Buffer.from(value, "base64"), which skips invalid characters and stops at the first =, it never decodes garbage.

Parameters​

value​

string

Returns​

Buffer<ArrayBufferLike> | null