{url2bin:data}

Description

Decodes a Base64url-encoded string back to its original bytes. It is the inverse of bin2url: it replaces - with + and _ with /, re-adds the stripped = padding, then runs standard Base64 decoding. Use it to read values that were packed into a URL path, query string, or filename with bin2url (RFC 4648 section 5). Decoding is tolerant - missing padding and a mixed +/_ and standard +/ alphabet both decode correctly. Undecodable input yields empty output.

Parameters

data optional

The Base64url-encoded string to decode. Decoding is tolerant: missing = padding is re-added and both the URL-safe -_ and standard +/ alphabets are accepted. The value is not trimmed before decoding. Undecodable input decodes to empty.

Examples

test{url2bin:SGVsbG8}
ExpectedHello
ActualHello
Decodes the Base64url text back to its original bytes.
test{url2bin:Zm9vYmFy}
Expectedfoobar
Actualfoobar
Base64url drops the = padding; url2bin restores it before decoding, so unpadded input decodes fine.
test{url2bin:SGVsbG8sIFdvcmxkIQ}
ExpectedHello, World!
ActualHello, World!
A typical round-trip target: text that travelled inside a URL or filename comes back unchanged.
test{url2bin:a2V5OiB2YWx1ZT8_}
Expectedkey: value??
Actualkey: value??
The URL-safe alphabet uses - and _ where standard Base64 uses + and /. url2bin maps them back, so an underscore in the encoded text decodes correctly.
test{url2bin:{bin2url:round trip}}
Expectedround trip
Actualround trip
url2bin is the exact inverse of bin2url: encoding then decoding returns the original value. This is the canonical pattern for packing a value into a URL and reading it back.