Send feedback
Function: base64.decode
Stay organized with collections
Save and categorize content based on your preferences.
Decodes given Base64-encoded string to bytes.
The carriage return (\r
) and newline (\n
) characters in the input
are ignored.
Arguments
Arguments
data
string
The input to be decoded.
padding
boolean
Specifies whether the input should be expected to be aligned to a multiple of 4 bytes, using a padding character (default: true
).
Returns
The decoded bytes.
Raised exceptions
Exceptions
ValueError
If characters outside of the Base64 alphabet are encountered, or if padding == true
and the input is not aligned to a multiple of 4 bytes.
Examples
For more information, see
Returning bytes .
# Decode Base64-encoded string to bytes, then decode bytes to object
- init :
assign :
- project : '${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}'
- subscription : SUBSCRIPTION_ID
- pullMessage : # pulls Pub/Sub message
call : googleapis.pubsub.v1.projects.subscriptions.pull
args :
subscription : '${"projects/" + project + "/subscriptions/" + subscription}'
body :
maxMessages : 1
result : m
- outputMessage :
return : '${json.decode(base64.decode(m.receivedMessages[0].message.data))}'
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-29 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 UTC."],[],[],null,["# Function: base64.decode\n\nDecodes given Base64-encoded string to bytes.\n\nThe carriage return (`\\r`) and newline (`\\n`) characters in the input\nare ignored.\n\nArguments\n---------\n\nReturns\n-------\n\nThe decoded bytes.\n\nRaised exceptions\n-----------------\n\nExamples\n--------\n\nFor more information, see\n[Returning bytes](https://cloud.google.com/workflows/docs/reference/syntax/datatypes.md#bytes). \n\n```yaml\n# Decode Base64-encoded string to bytes, then decode bytes to object\n- init:\n assign:\n - project: '${sys.get_env(\"GOOGLE_CLOUD_PROJECT_ID\")}'\n - subscription: SUBSCRIPTION_ID\n- pullMessage: # pulls Pub/Sub message\n call: googleapis.pubsub.v1.projects.subscriptions.pull\n args:\n subscription: '${\"projects/\" + project + \"/subscriptions/\" + subscription}'\n body:\n maxMessages: 1\n result: m\n- outputMessage:\n return: '${json.decode(base64.decode(m.receivedMessages[0].message.data))}'\n```"]]