/b64 Base64 Encode & Decode
Base64 in both directions, binary-safe. Pipe a string or a file in; add ?op=decode to go the other way. No more remembering base64 -d flags.
printf 'hello' | curl --data-binary @- curlhub.sh/b64
Usage
With curl
printf 'hello' | curl --data-binary @- curlhub.sh/b64
printf 'aGVsbG8=' | curl --data-binary @- 'curlhub.sh/b64?op=decode'
curl --data-binary @avatar.png curlhub.sh/b64
With the CLI
printf hello | curlhub b64
printf aGVsbG8= | curlhub 'b64?op=decode'
Structured output for scripts
printf 'hello' | curl -s --data-binary @- curlhub.sh/b64 -H 'Accept: application/json'
Output
printf 'hello' | curl --data-binary @- curlhub.sh/b64
# encode
aGVsbG8=
# decode (?op=decode)
hello
Parameters
| Input | What it does |
|---|---|
--data-binary @- | Read the payload from stdin — pipe a string, file, or command output. Binary-safe. |
?op=decode | Decode instead of encode. The default is encode. |
?data= | Small inline payload via the query string (URL-encode it). |
Recipes
Decode a JWT segment by hand
printf '<payload>' | curl --data-binary @- 'curlhub.sh/b64?op=decode'
Or just use /jwt, which splits and decodes all three parts for you.
Inline an image as a data URI
curl -s --data-binary @icon.png curlhub.sh/b64