Skip to main content

base64_decode_url_safe

Decode a Base64 string encoded with the URL-safe alphabet (RFC 4648 §5) back to UTF-8 text. The URL-safe alphabet uses - and _ instead of + and /. Padding (=) is accepted but not required.

For decoding standard Base64 (uses + and /), use base64_decode instead.

Parameters​

ParameterTypeRequiredDescription
inputstringYesThe URL-safe Base64 string to decode.

Response​

FieldTypeDescription
outputstringThe decoded UTF-8 plaintext.

Examples​

Decode a padded URL-safe Base64 string​

{
"input": "aGVsbG9-d29ybGQ="
}

Result:

{
"output": "hello~world"
}

The - character in the input is the URL-safe equivalent of + in standard Base64. Padding is optional — aGVsbG9-d29ybGQ (without the trailing =) decodes to the same value.

Decode an unpadded URL-safe Base64 string​

Padding is optional for the URL-safe variant. JWT tokens, for example, omit trailing = padding:

{
"input": "aGVsbG8"
}

Result:

{
"output": "hello"
}

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 contains characters not in the URL-safe Base64 alphabet (- and _).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 URL-safe Base64 string (uses - and _). Use base64_decode for standard encoded strings.
  • Padding (=) is optional — the URL-safe variant accepts both padded and unpadded input.
  • If the decoded bytes are not valid UTF-8, the tool returns an invalid_utf8 tool error (isError). This tool cannot handle binary payloads.