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
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The standard Base64 string to decode. |
Response
| Field | Type | Description |
|---|---|---|
output | string | The 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).
| Code | When | Delivered as |
|---|---|---|
invalid_arguments | The input field is missing or not a string. | protocol error (invalid_params) |
base64_decode_failed | The 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_utf8 | The input decoded successfully, but the resulting bytes are not valid UTF-8 text. | tool error (isError) |
internal_error | An unexpected server error. | protocol error (internal_error) |
Notes
- The input must be a valid standard Base64 string. Use
base64_decode_url_safefor 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_utf8tool error (isError). This tool cannot handle binary payloads.