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

POSTValidate

Check whether a string is Base64 before you use it. The answer includes the alphabet, the padding and the decoded size, or the reason it is not valid.

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

Request

The input is the same as for Decode: JSON with input, or the Base64 as a text/plain body.

curl -s https://api.base64hub.com/v1/validate \
  -H 'Content-Type: text/plain' \
  -d '-_-_'

Body parameters

NameTypeDescription
input requiredstringThe text to check.

Response

Validate always answers 200 for a well-formed request. Valid input:

200 OK · application/json
{
  "valid": true,
  "variant": "url",
  "padded": true,
  "bytes": 3
}

Invalid input, here Zm9vY:

200 OK · application/json
{
  "valid": false,
  "error": {
    "code": "invalid_base64",
    "message": "invalid length: 5 characters leave a single character in the last group"
  }
}
FieldTypeDescription
validbooleantrue exactly when Decode would succeed.
variantstringstandard if + or / occurs, url if - or _ occurs, mixed if both, either if neither.
paddedbooleanWhether the cleaned input, = included, is a multiple of 4 characters long.
bytesintegerSize of the decoded data.
errorobjectOnly when valid is false: code is invalid_base64, message describes the problem and its position.

either is common: SGVsbG8sIGh1YiE= contains none of the four special characters, so it is valid in both alphabets. padded: false does not make input invalid; SGVsbG8sIGh1YiE is valid with padded: false and 11 bytes.

Errors

Errors with a non-200 status are about the request, not the Base64:

StatusCodeCause
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.

Updated Nov 22, 2026