POSTKodieren
Text oder Bytes in Base64 umwandeln. Standard- oder URL-sicheres Alphabet, mit oder ohne Padding, auf Wunsch mit Zeilenumbruch.
https://api.base64hub.com/v1/encodeAnfrage
Senden Sie JSON mit dem Text in input. Der Text wird als UTF-8 kodiert.
curl -s https://api.base64hub.com/v1/encode \
-H 'Content-Type: application/json' \
-d '{"input": "Hello, hub!"}'
const res = await fetch("https://api.base64hub.com/v1/encode", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ input: "Hello, hub!" }),
});
const { output } = await res.json();
console.log(output); // SGVsbG8sIGh1YiE=
import json
import urllib.request
req = urllib.request.Request(
"https://api.base64hub.com/v1/encode",
data=json.dumps({"input": "Hello, hub!"}).encode(),
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(req) as res:
print(json.load(res)["output"]) # SGVsbG8sIGh1YiE=
b64 "Hello, hub!"
# SGVsbG8sIGh1YiE=
Body-Parameter
| Name | Typ | Beschreibung |
|---|---|---|
input erforderlich | string | Der zu kodierende Text. Er wird zuerst in UTF-8-Bytes umgewandelt. |
variant optional | "standard" oder "url" | Alphabet. url verwendet - und _ statt + und /. Standardwert "standard". |
padding optional | boolean | Das abschließende = behalten. Standardwert true. |
wrap optional | integer, 0 bis 1000 | Nach je N Ausgabezeichen \n einfügen, keins am Ende. 76 ist MIME. Standardwert 0, kein Umbruch. |
Jedes andere Feld wird mit 400 invalid_body abgelehnt.
Rohe Bytes
Um eine Datei oder beliebige Binärdaten zu kodieren, senden Sie die Bytes als application/octet-stream. Die Optionen stehen dann im Query-String: variant=url, padding=false, wrap=76.
printf '\xfb\xff\xbf' | curl -s \
'https://api.base64hub.com/v1/encode?variant=url&padding=false' \
-H 'Content-Type: application/octet-stream' \
--data-binary @-
const bytes = new Uint8Array([0xfb, 0xff, 0xbf]);
const res = await fetch(
"https://api.base64hub.com/v1/encode?variant=url&padding=false",
{ method: "POST", headers: { "Content-Type": "application/octet-stream" }, body: bytes },
);
console.log((await res.json()).output); // -_-_
import json
import urllib.request
req = urllib.request.Request(
"https://api.base64hub.com/v1/encode?variant=url&padding=false",
data=b"\xfb\xff\xbf",
headers={"Content-Type": "application/octet-stream"},
)
with urllib.request.urlopen(req) as res:
print(json.load(res)["output"]) # -_-_
printf '\xfb\xff\xbf' | b64 --url --no-pad
# -_-_
Das Body-Limit liegt bei 1 MB. Für größere Dateien nehmen Sie das CLI, das streamt.
Antwort
{
"output": "SGVsbG8sIGh1YiE=",
"variant": "standard",
"padding": true,
"bytes_in": 11,
"bytes_out": 16
}
| Feld | Typ | Beschreibung |
|---|---|---|
output | string | Der Base64-Text. |
variant | string | Das verwendete Alphabet, standard oder url. |
padding | boolean | Ob das =-Padding behalten wurde. |
bytes_in | integer | Anzahl der Eingabebytes nach der Umwandlung in UTF-8. |
bytes_out | integer | Länge von output, Zeilenumbrüche eingeschlossen. |
Mit {"input": "foobar", "wrap": 4} ist die Ausgabe "Zm9v\nYmFy" und bytes_out gleich 9: acht Base64-Zeichen und ein Zeilenumbruch. Die Antwort oben ist zum Lesen formatiert; die API sendet sie in einer Zeile.
Fehler
| Status | Code | Ursache |
|---|---|---|
| 400 | invalid_body | Kein gültiges JSON, input fehlt oder ist kein String, ein ungültiger Wert für variant, padding oder wrap, ein unbekanntes Feld oder ein Query-Parameter, oder Query-Optionen zusammen mit einem JSON-Body. |
| 413 | too_large | Der Body ist größer als 1 MB. |
| 415 | unsupported_media_type | Content-Type ist weder application/json noch application/octet-stream. |
| 429 | keiner | Rate-Limit erreicht; siehe Limits. |
Die API-Übersicht listet alle Fehler.
Aktualisiert 22.11.2026