base64_decode

base64_decode

Decodes a Base64-encoded string back to its original text. Useful for reading encoded API responses, decoding authentication tokens, or processing encoded webhook payloads.

{% assign decoded = "SGVsbG8sIFdvcmxkIQ==" | base64_decode %}
{% log decoded %}

Output:

Hello, World!

Syntax

{{ base64_string | base64_decode }}
Parameter
Description

base64_string

The Base64-encoded string to decode

Examples

Decode API response data:

{% http options: api_request as response %}

{% if response.body.encoded_data %}
  {% assign decoded_data = response.body.encoded_data | base64_decode %}
  {% assign parsed_data = decoded_data | parse %}

  {% log "Decoded response:" %}
  {% log parsed_data %}
{% endif %}

Decode webhook payload:

Decode URL parameter data:

Decode Basic Auth header (for debugging):

Process encoded email content:

Decode international characters:

Output:

Decode and parse JSON from encoded parameter:

Handle URL-safe Base64:

Decode and validate signature data:

Decode embedded file content:

Encoding Round-Trip

Output:

Error Handling

Notes

  • Supports UTF-8 decoding (handles international characters correctly)

  • Expects standard Base64 input (with +, /, and = padding)

  • For URL-safe Base64, convert - to + and _ to / before decoding

  • Invalid Base64 input may produce unexpected results or empty output

  • Decoding does not validate the content - always validate decoded data before use

  • See also: base64_encode for encoding strings to Base64

Last updated