What is base64.standard_b64decode(s) in Python?

The base64.standard_b64decode() method decodes an encoded bytes-like object into its original byte string using Base64 alphabets.

standard_b64decode() method

Syntax

We can import standard_b64decode from base64 using the following code:

from base64 import standard_b64decode

The declaration of the base64.standard_b64decode() method is as follows:

base64.standard_b64decode(b_string)

The method returns the decoded byte-string.

Code

The code below demonstrates the use of base64.standard_b64decode():

from base64 import standard_b64encode
from base64 import standard_b64decode
b_str = b'Welcome to Educative!'
print('Data type of \'s\': ', type(b_str))
enc_str = standard_b64encode(b_str) # encode
dec_str = standard_b64decode(enc_str) # decode
print('Data type of decoded \'dec_str\': ', type(dec_str))
print('Decoded string: ', dec_str)

Explanation

In line 4, a byte string is initialized and stored in b_str. The next line prints the type of b_str. In line 7, the string is encoded, then in line 8, the string is decoded, and finally line 9 prints the type of the encoded string. Lastly, in line 11, the encoded string is printed.

Free Resources

Copyright ©2026 Educative, Inc. All rights reserved