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
| Method | Path | Purpose |
|---|---|---|
POST | /v1/encode | text or raw bytes to Base64 |
POST | /v1/decode | Base64 to text, hex or raw bytes |
POST | /v1/validate | check Base64 and describe it |
GET | /v1/health | status and version |
GET | /v1/openapi.json | OpenAPI 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.
| Endpoint | Content-Type | Body |
|---|---|---|
| encode | application/json | {"input": "<text>", "variant", "padding", "wrap"} |
| encode | application/octet-stream | raw bytes; options in the query string |
| decode, validate | application/json | {"input": "<base64>"} |
| decode, validate | text/plain | the 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 status429with 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"}}
| Status | Code | When |
|---|---|---|
| 400 | invalid_body | malformed JSON, wrong field types, a missing input, unknown fields or query parameters, a body that is not UTF-8 |
| 400 | invalid_base64 | decode input is not Base64; the message names the problem and its position |
| 404 | not_found | unknown path |
| 405 | method_not_allowed | wrong method for the path; the Allow header lists the right ones |
| 413 | too_large | body over 1 MB |
| 415 | unsupported_media_type | a Content-Type the endpoint does not accept |
| 429 | none | rate limit reached; the response comes from Cloudflare, not as JSON |
| 500 | internal_error | an 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