happy-codec
    Preparing search index...

    Function decodeBase64

    • Converts a Base64 encoded string to Uint8Array.

      Uses native Uint8Array.fromBase64 if available, otherwise pure JS fallback.

      Parameters

      Returns Uint8Array<ArrayBuffer>

      Decoded Uint8Array.

      If the input is not a string.

      If the input contains invalid characters for the chosen alphabet.

      If the input has an invalid length (trailing single character).

      If options.lastChunkHandling is 'strict' and padding is missing or padding bits are non-zero.

      1.0.0

      const buffer = decodeBase64('SGVsbG8=');
      console.log(buffer); // Uint8Array [72, 101, 108, 108, 111]

      // Decode to string
      const text = decodeUtf8(decodeBase64('SGVsbG8sIFdvcmxkIQ=='));
      console.log(text); // 'Hello, World!'

      // Base64url input
      const bytes = decodeBase64('SGVsbG8', { alphabet: 'base64url' });

      // Strict mode: require correct padding
      decodeBase64('QQ==', { lastChunkHandling: 'strict' });