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

HTTP API Overview

A small JSON API for Base64 at https://api.base64hub.com/v1. No key, no account, CORS enabled. This page covers what every endpoint has in common.

Base URL and endpoints

https://api.base64hub.com/v1
MethodPathPurpose
POST/v1/encodetext or raw bytes to Base64
POST/v1/decodeBase64 to text, hex or raw bytes
POST/v1/validatecheck Base64 and describe it
GET/v1/healthstatus and version
GET/v1/openapi.jsonOpenAPI 3.1 description of the API

GET https://api.base64hub.com/ redirects (302) to this page. Requests need no authentication.

Request formats

Each endpoint accepts a fixed set of content types and answers anything else with 415 unsupported_media_type.

EndpointContent-TypeBody
encodeapplication/json{"input": "<text>", "variant", "padding", "wrap"}
encodeapplication/octet-streamraw bytes; options in the query string
decode, validateapplication/json{"input": "<base64>"}
decode, validatetext/plainthe Base64 itself

Bodies must be UTF-8 (except raw bytes for encode). Unknown JSON fields and unknown query parameters are rejected with 400 invalid_body instead of being ignored, so a misspelled option never fails silently. Query options are read only together with an application/octet-stream body.

Responses are JSON (application/json; charset=utf-8), except decode with Accept: application/octet-stream, which returns the raw bytes.

CORS and headers

Every response carries:

Access-Control-Allow-Origin: *
Cache-Control: no-store
X-Content-Type-Options: nosniff

Preflight OPTIONS requests get 204 with the allowed methods and the Content-Type and Accept request headers, so the API can be called with fetch() from any web page.

Limits

  • Body size: 1 MB (1048576 bytes). Larger bodies get 413 too_large.
  • Rate limit: 20 requests per 10 seconds per IP address on paths under /v1/. The limit is enforced by Cloudflare in front of the API. Over it you get status 429 with Cloudflare’s own response, which is not JSON and has no CORS header, so a browser script sees a network error rather than a readable body.
  • Wrap: from 0 to 1000 characters.

The API keeps no state and does not log request bodies. For large files or secrets, use a local tool such as the b64 CLI.

Errors

Errors from the API itself are JSON with a stable code and a human-readable message:

{"error":{"code":"invalid_base64","message":"invalid character '!' at position 4"}}
StatusCodeWhen
400invalid_bodymalformed JSON, wrong field types, a missing input, unknown fields or query parameters, a body that is not UTF-8
400invalid_base64decode input is not Base64; the message names the problem and its position
404not_foundunknown path
405method_not_allowedwrong method for the path; the Allow header lists the right ones
413too_largebody over 1 MB
415unsupported_media_typea Content-Type the endpoint does not accept
429nonerate limit reached; the response comes from Cloudflare, not as JSON
500internal_erroran unexpected failure in the API

Validate reports invalid Base64 with status 200, because “not valid” is the answer to the question it was asked. See Validate.

OpenAPI

The machine-readable description lives at https://api.base64hub.com/v1/openapi.json. Import it into an API client or a code generator to get ready-made requests for every endpoint.

Updated Nov 22, 2026