POSTDecode
Turn Base64 back into text, or into the original bytes. The input may use either alphabet, skip the padding or carry a data: prefix.
https://api.base64hub.com/v1/decodeRequest
Send the Base64 as JSON in input, or as the whole body with Content-Type: text/plain.
curl -s https://api.base64hub.com/v1/decode \
-H 'Content-Type: application/json' \
-d '{"input": "SGVsbG8sIGh1YiE="}'
const res = await fetch("https://api.base64hub.com/v1/decode", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ input: "SGVsbG8sIGh1YiE=" }),
});
const data = await res.json();
console.log(data.output); // Hello, hub!
import json
import urllib.request
req = urllib.request.Request(
"https://api.base64hub.com/v1/decode",
data=json.dumps({"input": "SGVsbG8sIGh1YiE="}).encode(),
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(req) as res:
print(json.load(res)["output"]) # Hello, hub!
b64 -d SGVsbG8sIGh1YiE=
# Hello, hub!
Body parameters
| Name | Type | Description |
|---|---|---|
input required | string | The Base64 to decode. |
With Content-Type: text/plain the whole body is the input, with no JSON around it. Query parameters are not accepted on this endpoint.
What the decoder accepts:
- spaces, tabs and line breaks anywhere, for example MIME-wrapped Base64;
- a
data:<type>;base64,prefix, which is removed; - missing
=padding; - the standard and the URL-safe alphabet, even mixed.
Response
{
"output": "Hello, hub!",
"utf8": true,
"bytes_out": 11
}
When the decoded bytes are not valid UTF-8, output is null and the bytes come as hex. This is the response for +/+/:
{
"output": null,
"utf8": false,
"hex": "fbffbf",
"bytes_out": 3
}
| Field | Type | Description |
|---|---|---|
output | string or null | The decoded text, or null when the bytes are not UTF-8. |
utf8 | boolean | Whether the bytes are valid UTF-8. |
hex | string | The bytes in lowercase hex. Present only when utf8 is false. |
bytes_out | integer | Number of decoded bytes. |
Raw bytes
To get a file back, ask for the bytes with Accept: application/octet-stream. The response body is then the decoded data with no JSON around it.
curl -s https://api.base64hub.com/v1/decode \
-H 'Content-Type: text/plain' \
-H 'Accept: application/octet-stream' \
--data-binary @photo.b64 -o photo.jpg
const res = await fetch("https://api.base64hub.com/v1/decode", {
method: "POST",
headers: { "Content-Type": "text/plain", Accept: "application/octet-stream" },
body: "SGk=",
});
const bytes = new Uint8Array(await res.arrayBuffer());
console.log(bytes); // Uint8Array(2) [ 72, 105 ]
import urllib.request
req = urllib.request.Request(
"https://api.base64hub.com/v1/decode",
data=b"SGk=",
headers={"Content-Type": "text/plain", "Accept": "application/octet-stream"},
)
with urllib.request.urlopen(req) as res:
print(res.read()) # b'Hi'
b64 -d -i photo.b64 -o photo.jpg
Errors
Invalid Base64 is rejected with 400 invalid_base64. The message names the first problem and its position, counted from 0 after whitespace is removed:
{"error":{"code":"invalid_base64","message":"invalid character '!' at position 4"}}
| Status | Code | Cause |
|---|---|---|
| 400 | invalid_base64 | A character outside both alphabets, = in the middle, more than two =, or a length that leaves one character in the last group. |
| 400 | invalid_body | Not valid JSON, input missing or not a string, an unknown field, a query parameter, or a body that is not UTF-8. |
| 413 | too_large | The body is over 1 MB. |
| 415 | unsupported_media_type | Content-Type is not application/json or text/plain. |
| 429 | none | Rate limit reached; see limits. |
To check a string without getting an error status, use Validate.
Updated Nov 22, 2026