Encode / Decode API
Encode or decode text as Base64, Base64URL, hex, URL encoding, HTML entities, Unicode escapes, ROT13 or binary with one simple API call.
The Encode API converts text to and from the encodings developers deal with every day. Choose a scheme – base64, base64url, hex, url, html, unicode, rot13 or binary – and an action (encode, the default, or decode). Everything is UTF-8 aware, so Vietnamese, emoji and other non-ASCII text survive a round trip through Base64 or hex.
Details per scheme: base64url encodes without padding (JWT style); hex decoding ignores spaces and a 0x prefix; url uses percent-encoding (and turns + into spaces when decoding); html escapes & < > " ' and decodes named and numeric entities; unicode turns non-ASCII characters into \uXXXX escapes; binary outputs 8-bit groups separated by spaces.
Send text in the query string or a JSON body, or post the text as a raw text/plain body. The result comes back in a small JSON object together with the scheme and action used. Invalid input for a decode (for example broken Base64) returns a clear decode_error.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
text | body|query | string | yes | Text to encode or decode (or send it as a raw text/plain body). | |
scheme | body|query | string | no | base64 | base64, base64url, hex, url, html, unicode, rot13 or binary. |
action | body|query | string | no | encode | encode or decode. |
Example
curl -X POST "https://apibox.io.vn/v1/encode" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"Xin chào APIBox","scheme":"base64"}'const res = await fetch('https://apibox.io.vn/v1/encode', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"text": "Xin chào APIBox",
"scheme": "base64"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/encode",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"text": "Xin chào APIBox", "scheme": "base64"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/encode');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"text":"Xin chào APIBox","scheme":"base64"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"scheme": "base64",
"action": "encode",
"result": "WGluIGNow6BvIEFQSUJveA=="
}
Use cases
- Decode Base64 payloads from logs, e-mails or API responses
- URL-encode query parameters before building links
- Escape user content as HTML entities before rendering
- Inspect the raw bytes of a string as hex or binary
FAQ
What is the difference between Base64 and Base64URL?
Base64URL replaces + and / with - and _ and drops the = padding so the result is safe in URLs and JWTs. Decoding with either scheme accepts both alphabets.
Does it handle Vietnamese and emoji?
Yes. Text is converted to UTF-8 bytes before encoding and decoded back from UTF-8, so "Xin chào" becomes "WGluIGNow6Bv" in Base64 and decodes back unchanged.
Is this encryption?
No. Base64, hex, URL encoding and ROT13 are reversible encodings that anyone can decode. To protect data use real encryption; to fingerprint it use /v1/hash.
Related APIs
Hash Generator
Compute MD5, SHA-1, SHA-256, SHA-384, SHA-512 and CRC32 of text or files in one call, as hex or base64, with optional HMAC signing.
***Password Generator
Generate cryptographically secure random passwords (4–256 chars, up to 100 at once) or check a password’s strength, entropy and estimated crack time.
JWTJWT Decode & Sign
Decode any JWT, check expiry and verify its signature with a secret, PEM or JWK – or sign new tokens with HS256/384/512, RS, PS or ES algorithms.