Upload a file
  1. base64hub
  2. Docs
  3. HTTP API
  4. Decode

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.

POSThttps://api.base64hub.com/v1/decode

Request

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="}'

Body parameters

NameTypeDescription
input requiredstringThe 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

200 OK · application/json
{
  "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 +/+/:

200 OK · application/json
{
  "output": null,
  "utf8": false,
  "hex": "fbffbf",
  "bytes_out": 3
}
FieldTypeDescription
outputstring or nullThe decoded text, or null when the bytes are not UTF-8.
utf8booleanWhether the bytes are valid UTF-8.
hexstringThe bytes in lowercase hex. Present only when utf8 is false.
bytes_outintegerNumber 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

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:

400 Bad Request · application/json
{"error":{"code":"invalid_base64","message":"invalid character '!' at position 4"}}
StatusCodeCause
400invalid_base64A character outside both alphabets, = in the middle, more than two =, or a length that leaves one character in the last group.
400invalid_bodyNot valid JSON, input missing or not a string, an unknown field, a query parameter, or a body that is not UTF-8.
413too_largeThe body is over 1 MB.
415unsupported_media_typeContent-Type is not application/json or text/plain.
429noneRate limit reached; see limits.

To check a string without getting an error status, use Validate.

Updated Nov 22, 2026