import base64
coded_string = '''Q5YACgA...'''
base64.b64decode(coded_string)

worked for me. At the risk of pasting an offensively-long result, I got:

>>> base64.b64decode(coded_string)
2: 'C\x96\x00\n\x00\x00\x00\x00C\x96\x00\x1b\x00\x00\x00\x00C\x96\x00-\x00\x00\x00\x00C\x96\x00?\x00\x00\x00\x00C\x96\x07M\x00\x00\x00\x00C\x96\x07_\x00\x00\x00\x00C\x96\x07p\x00\x00\x00\x00C\x96\x07\x82\x00\x00\x00\x00C\x96\x07\x94\x00\x00\x00\x00C\x96\x07\xa6Cq\xf0\x7fC\x96\x07\xb8DJ\x81\xc7C\x96\x07\xcaD\xa5\x9dtC\x96\x07\xdcD\xb6\x97\x11C\x96\x07\xeeD\x8b\x8flC\x96\x07\xffD\x03\xd4\xaaC\x96\x08\x11B\x05&\xdcC\x96\x08#\x00\x00\x00\x00C\x96\x085C\x0c\xc9\xb7C\x96\x08GCy\xc0\xebC\x96\x08YC\x81\xa4xC\x96\x08kC\x0f@\x9bC\x96\x08}\x00\x00\x00\x00C\x96\x08\x8e\x00\x00\x00\x00C\x96\x08\xa0\x00\x00\x00\x00C\x96\x08\xb2\x00\x00\x00\x00C\x96\x86\xf9\x00\x00\x00\x00C\x96\x87\x0b\x00\x00\x00\x00C\x96\x87\x1d\x00\x00\x00\x00C\x96\x87/\x00\x00\x00\x00C\x96\x87AA\x0b\xe7PC\x96\x87SCI\xf5gC\x96\x87eC\xd4J\xeaC\x96\x87wD\r\x17EC\x96\x87\x89D\x00F6C\x96\x87\x9bC\x9cg\xdeC\x96\x87\xadB\xd56\x0cC\x96\x87\xbf\x00\x00\x00\x00C\x96\x87\xd1\x00\x00\x00\x00C\x96\x87\xe3\x00\x00\x00\x00C\x96\x87\xf5\x00\x00\x00\x00C\x9cY}\x00\x00\x00\x00C\x9cY\x90\x00\x00\x00\x00C\x9cY\xa4\x00\x00\x00\x00C\x9cY\xb7\x00\x00\x00\x00C\x9cY\xcbC\x1f\xbd\xa3C\x9cY\xdeCCz{C\x9cY\xf1CD\x02\xa7C\x9cZ\x05C+\x9d\x97C\x9cZ\x18C\x03R\xe3C\x9cZ,\x00\x00\x00\x00C\x9cZ?
[stuff omitted as it exceeded SO's body length limits]
\xbb\x00\x00\x00\x00D\xc5!7\x00\x00\x00\x00D\xc5!\xb2\x00\x00\x00\x00D\xc7\x14x\x00\x00\x00\x00D\xc7\x14\xf6\x00\x00\x00\x00D\xc7\x15t\x00\x00\x00\x00D\xc7\x15\xf2\x00\x00\x00\x00D\xc7\x16pC5\x9f\xf9D\xc7\x16\xeeC[\xb5\xf5D\xc7\x17lCG\x1b;D\xc7\x17\xeaB\xe3\x0b\xa6D\xc7\x18h\x00\x00\x00\x00D\xc7\x18\xe6\x00\x00\x00\x00D\xc7\x19d\x00\x00\x00\x00D\xc7\x19\xe2\x00\x00\x00\x00D\xc7\xfe\xb4\x00\x00\x00\x00D\xc7\xff3\x00\x00\x00\x00D\xc7\xff\xb2\x00\x00\x00\x00D\xc8\x001\x00\x00\x00\x00'
Answer from Blair Conrad on Stack Overflow
🌐
Python
docs.python.org › 3 › library › base64.html
base64 — Base16, Base32, Base64, Base85 Data Encodings
Encode the bytes-like object s, which can contain arbitrary binary data, and return bytes containing the base64-encoded data, with newlines (b'\n') inserted after every 76 bytes of output, and ensuring that there is a trailing newline, as per RFC 2045 (MIME). Added in version 3.1. ... >>> import base64 >>> encoded = base64.b64encode(b'data to be encoded') >>> encoded b'ZGF0YSB0byBiZSBlbmNvZGVk' >>> data = base64.b64decode(encoded) >>> data b'data to be encoded'
Top answer
1 of 10
450
import base64
coded_string = '''Q5YACgA...'''
base64.b64decode(coded_string)

worked for me. At the risk of pasting an offensively-long result, I got:

>>> base64.b64decode(coded_string)
2: 'C\x96\x00\n\x00\x00\x00\x00C\x96\x00\x1b\x00\x00\x00\x00C\x96\x00-\x00\x00\x00\x00C\x96\x00?\x00\x00\x00\x00C\x96\x07M\x00\x00\x00\x00C\x96\x07_\x00\x00\x00\x00C\x96\x07p\x00\x00\x00\x00C\x96\x07\x82\x00\x00\x00\x00C\x96\x07\x94\x00\x00\x00\x00C\x96\x07\xa6Cq\xf0\x7fC\x96\x07\xb8DJ\x81\xc7C\x96\x07\xcaD\xa5\x9dtC\x96\x07\xdcD\xb6\x97\x11C\x96\x07\xeeD\x8b\x8flC\x96\x07\xffD\x03\xd4\xaaC\x96\x08\x11B\x05&\xdcC\x96\x08#\x00\x00\x00\x00C\x96\x085C\x0c\xc9\xb7C\x96\x08GCy\xc0\xebC\x96\x08YC\x81\xa4xC\x96\x08kC\x0f@\x9bC\x96\x08}\x00\x00\x00\x00C\x96\x08\x8e\x00\x00\x00\x00C\x96\x08\xa0\x00\x00\x00\x00C\x96\x08\xb2\x00\x00\x00\x00C\x96\x86\xf9\x00\x00\x00\x00C\x96\x87\x0b\x00\x00\x00\x00C\x96\x87\x1d\x00\x00\x00\x00C\x96\x87/\x00\x00\x00\x00C\x96\x87AA\x0b\xe7PC\x96\x87SCI\xf5gC\x96\x87eC\xd4J\xeaC\x96\x87wD\r\x17EC\x96\x87\x89D\x00F6C\x96\x87\x9bC\x9cg\xdeC\x96\x87\xadB\xd56\x0cC\x96\x87\xbf\x00\x00\x00\x00C\x96\x87\xd1\x00\x00\x00\x00C\x96\x87\xe3\x00\x00\x00\x00C\x96\x87\xf5\x00\x00\x00\x00C\x9cY}\x00\x00\x00\x00C\x9cY\x90\x00\x00\x00\x00C\x9cY\xa4\x00\x00\x00\x00C\x9cY\xb7\x00\x00\x00\x00C\x9cY\xcbC\x1f\xbd\xa3C\x9cY\xdeCCz{C\x9cY\xf1CD\x02\xa7C\x9cZ\x05C+\x9d\x97C\x9cZ\x18C\x03R\xe3C\x9cZ,\x00\x00\x00\x00C\x9cZ?
[stuff omitted as it exceeded SO's body length limits]
\xbb\x00\x00\x00\x00D\xc5!7\x00\x00\x00\x00D\xc5!\xb2\x00\x00\x00\x00D\xc7\x14x\x00\x00\x00\x00D\xc7\x14\xf6\x00\x00\x00\x00D\xc7\x15t\x00\x00\x00\x00D\xc7\x15\xf2\x00\x00\x00\x00D\xc7\x16pC5\x9f\xf9D\xc7\x16\xeeC[\xb5\xf5D\xc7\x17lCG\x1b;D\xc7\x17\xeaB\xe3\x0b\xa6D\xc7\x18h\x00\x00\x00\x00D\xc7\x18\xe6\x00\x00\x00\x00D\xc7\x19d\x00\x00\x00\x00D\xc7\x19\xe2\x00\x00\x00\x00D\xc7\xfe\xb4\x00\x00\x00\x00D\xc7\xff3\x00\x00\x00\x00D\xc7\xff\xb2\x00\x00\x00\x00D\xc8\x001\x00\x00\x00\x00'
2 of 10
224

Python 3 (and 2)

import base64
a = 'eW91ciB0ZXh0'
base64.b64decode(a)

Python 2

A quick way to decode it without importing anything:

'eW91ciB0ZXh0'.decode('base64')

or more descriptive

>>> a = 'eW91ciB0ZXh0'
>>> a.decode('base64')
'your text'
🌐
PyPI
pypi.org › project › pybase64
pybase64 · PyPI
To get the fastest decoding, it is recommended to use the pybase64.b64decode and validate=True when possible. import pybase64 print(pybase64.b64encode(b'>>>foo???', altchars='_:')) ...
      » pip install pybase64
    
Published   Dec 06, 2025
Version   1.4.3
🌐
W3Schools
w3schools.com › Python › ref_module_base64.asp
Python base64 Module
Python Examples Python Compiler ... Training · ❮ Standard Library Modules · Encode and decode a string using Base64: import base64 s = "Linus".encode() b = base64.b64encode(s) print(b) print(base64.b64decode(b).decode()) ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › encoding-and-decoding-base64-strings-in-python
Encoding and Decoding Base64 Strings in Python - GeeksforGeeks
August 7, 2024 - In Python the base64 module is used to encode and decode data. First, the strings are converted into byte-like objects and then encoded using the base64 module. The below example shows the implementation of encoding strings isn't base64 characters.
🌐
Bacancy Technology
bacancytechnology.com › qanda › python › decode-base64-data-in-python
How to Decode Base64 Data in Python Easily
June 24, 2025 - Example: Decoding Base64 Data Here’s how to decode a Base64 string using Python: import base64 # Your Base64-encoded string b64_data = 'ABCSSDURN' # Convert to bytes, if it's a string decoded_bytes = base64.b64decode(b64_data) # If the original ...
🌐
DEV Community
dev.to › atifwattoo › what-is-base64-string-in-python-4joo
What is base64 string in Python? - DEV Community
December 23, 2024 - A base64 string is a way of encoding binary data (like images, audio, or files) into a text format....
🌐
GeeksforGeeks
geeksforgeeks.org › python › base64-b64decode-in-python
base64.b64decode() in Python - GeeksforGeeks
March 26, 2020 - # import base64 from base64 import b64decode from base64 import b64encode s = b'Hello World' s = b64encode(s) # Using base64.b64decode() method gfg = b64decode(s) print(gfg)
Find elsewhere
🌐
GitHub
gist.github.com › juliensalinas › 15789d241f28b1ce45f0c22e11ba894a
Encoding a file in base 64 in Python · GitHub
Encoding a file in base 64 in Python · Raw · base64_encode.py · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
Stepsecurity
stepsecurity.io › blog › forcememo-hundreds-of-github-python-repos-compromised-via-account-takeover-and-force-push
ForceMemo: Hundreds of GitHub Python Repos Compromised via Account Takeover and Force-Push - StepSecurity
The variable names are randomized 15-character strings, but the base64 payload blob is identical across all compromised repos, stored in a variable named lzcdrtfxyqiplpd. # Obfuscation wrapper (appended to end of legitimate Python file) # -*- coding: utf-8 -*- aqgqzxkfjzbdnhz = __import__('base64') ...
🌐
FastAPI
fastapi.tiangolo.com › tutorial › body
Request Body - FastAPI
First, you need to import BaseModel from pydantic:
🌐
Arashtad
press.arashtad.com › wp-content › uploads › pdf › Python_Simple_Encryption_Base64_Encode-Decode_a_File.pdf pdf
Simple Base64 File Encode and Decode in Python
This tutorial demonstrates encoding a file to Base64 and decoding it back using Python's · built-in base64 module. Step 1: Import base64 and pathlib · import base64 · from pathlib import Path · Step 2: Define encode and decode functions ·
🌐
AskPython
askpython.com › home › encoding an image file with base64 in python
Encoding an Image File With BASE64 in Python - AskPython
April 29, 2023 - Encoding an image file with Base64 in Python can be done easily using the base64 module. To encode an image, first, import the base64 module. Then, open the image file in binary mode and read its content.
🌐
Apiyi.com Blog
help.apiyi.com › home
Resolving Nano Banana 2 Image API Errors: 3 Steps to Switch to the Correct generateContent Invocation Format - Apiyi.com Blog
March 15, 2026 - import requests import base64 import os from typing import Optional def generate_image( prompt: str, model: str = "gemini-3.1-flash-image-preview", aspect_ratio: str = "1:1", output_path: str = "output.png", api_key: Optional[str] = None ) -> dict: """ Generate images using the Nano Banana 2 generateContent endpoint Args: prompt: Image description model: Model name aspect_ratio: Aspect ratio (1:1, 16:9, 9:16, 4:3, 3:4) output_path: Output file path api_key: API key Returns: Dictionary containing file path and model description """ api_key = api_key or os.getenv("APIYI_API_KEY") base_url = "htt
🌐
Zelatech
base64decode.it › home › developer guides › base64 decode & encode in python — base64 module examples (b64encode, b64decode)
Base64 Decode & Encode in Python — base64 Module Examples (b64encode, b64decode) | Base64 Decode.it
May 2, 2026 - import base64 encoded = "iVBORw0KGgo..." # Base64 string with open('output.png', 'wb') as f: f.write(base64.b64decode(encoded)) ... # Encode python -c "import base64; print(base64.b64encode(b'Hello').decode())" # Decode python -c "import base64; print(base64.b64decode('SGVsbG8=').decode())"