Skip to main content

base64_decode

Decode a Base64 string encoded with the standard alphabet (RFC 4648 §4) back to UTF-8 text. The standard alphabet uses + and /. Padding (=) is required.

For decoding URL-safe Base64 (uses - and _), use base64_decode_url_safe instead.

Parameters​

ParameterTypeRequiredDescription
inputstringYesThe standard Base64 string to decode.

Response​

FieldTypeDescription
outputstringThe decoded UTF-8 plaintext.

Examples​

Decode a padded standard Base64 string​

{
"input": "aGVsbG8gd29ybGQ="
}

Result:

{
"output": "hello world"
}

Attempt to decode an invalid string​

Passing a string that contains characters outside the standard Base64 alphabet returns an error:

{
"input": "!!!invalid!!!"
}

Result:

{
"isError": true,
"structuredContent": {
"error": {
"code": "base64_decode_failed",
"message": "base64 decode error: Invalid symbol 33, offset 0.",
"details": null
}
}
}

Errors​

Each failure carries a precise code in the response. Argument-schema and server errors are JSON-RPC protocol errors; a rejected value is returned as a tool result with isError: true (so the agent can read the code and self-correct).

CodeWhenDelivered as
invalid_argumentsThe input field is missing or not a string.protocol error (invalid_params)
base64_decode_failedThe input is not valid standard Base64 — it contains characters outside the standard alphabet, or the required = padding is missing or malformed.tool error (isError)
invalid_utf8The input decoded successfully, but the resulting bytes are not valid UTF-8 text.tool error (isError)
internal_errorAn unexpected server error.protocol error (internal_error)

Notes​

  • The input must be a valid standard Base64 string. Use base64_decode_url_safe for URL-safe encoded strings.
  • Padding (=) is required for the standard variant. Missing or incorrect padding will cause a decode error.
  • If the decoded bytes are not valid UTF-8, the tool returns an invalid_utf8 tool error (isError). This tool cannot handle binary payloads.