Skip to main content

Base Encoding and Decoding API

REAL DATA

Strict RFC 4648 base16, base32, base64 and base64url encoding/decoding with Unicode-safe UTF-8, padding control and malformed-input errors.

Authoritative reference data or standards computation

Base URL
/api/base-encodings
Capabilities
2 routes
Last updated
July 30, 2026
Data source

GET /api/base-encodings/encode

Live requestRuns against the public API
No key required
GET/api/base-encodings/encode?text=Hello%2C+K%C3%B8benhavn+%F0%9F%91%8B&encoding=base64

Request parameters

Unicode text to encode exactly as UTF-8 (1–4,096 characters); surrounding whitespace and a leading BOM are preserved.

RFC 4648 alphabet to use: hexadecimal base16, base32, standard base64, or URL-safe base64url.

Emit trailing '=' padding for base32/base64/base64url. Base16 has no padding.

Advanced response options4 options

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

Return all fields except these (comma-separated).

Pretty-print the JSON response.

Drop the envelope: return the raw array/object without data/meta wrapper.

Response

Example parameters are ready. Send the request to inspect the live response.

Route reference

Code samples Ready-to-copy requests in 4 languages
Choose a code sample language
curl "https://randomapi.dev/api/base-encodings/encode?text=Hello%2C%20K%C3%B8benhavn%20%F0%9F%91%8B&encoding=base64"
const res = await fetch("https://randomapi.dev/api/base-encodings/encode?text=Hello%2C%20K%C3%B8benhavn%20%F0%9F%91%8B&encoding=base64");
const { data, meta } = await res.json();
import requests

data = requests.get("https://randomapi.dev/api/base-encodings/encode?text=Hello%2C%20K%C3%B8benhavn%20%F0%9F%91%8B&encoding=base64").json()["data"]
$json = json_decode(file_get_contents(
  "https://randomapi.dev/api/base-encodings/encode?text=Hello%2C%20K%C3%B8benhavn%20%F0%9F%91%8B&encoding=base64"
), true);
$data = $json["data"];
Parameters Route-specific request inputs 3
text string required

Unicode text to encode exactly as UTF-8 (1–4,096 characters); surrounding whitespace and a leading BOM are preserved.

allowed: 1 – 4096
example: text=Hello, København 👋
encoding enum

RFC 4648 alphabet to use: hexadecimal base16, base32, standard base64, or URL-safe base64url.

default: base64
allowed: base16 | base32 | base64 | base64url
example: encoding=base64url
padding boolean

Emit trailing '=' padding for base32/base64/base64url. Base16 has no padding.

default: true
example: padding=false
Universal parameters Shared response and formatting options 4
fields list

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

example: fields=input,encoding
exclude list

Return all fields except these (comma-separated).

example: exclude=padded
pretty boolean

Pretty-print the JSON response.

default: false
example: pretty=true
unwrap boolean

Drop the envelope: return the raw array/object without data/meta wrapper.

default: false
example: unwrap=true
Response schema Fields returned in each record 5
input string

Original Unicode text.

example: Hello

encoding string

Selected RFC 4648 encoding.

example: base64

output string

Encoded bytes in the selected alphabet.

example: SGVsbG8=

bytes integer

Number of UTF-8 input bytes.

example: 5

padded boolean

Whether output ends in RFC 4648 '=' padding.

example: true

Documented examples

Build-generated requests and complete responses
3
Unicode text as standard base64
GET /api/base-encodings/encode?text=Hello%2C%20K%C3%B8benhavn%20%F0%9F%91%8B&encoding=base64
{
  "data": {
    "input": "Hello, København 👋",
    "encoding": "base64",
    "output": "SGVsbG8sIEvDuGJlbmhhdm4g8J+Riw==",
    "bytes": 22,
    "padded": true
  },
  "meta": {
    "endpoint": "base-encodings",
    "route": "/encode",
    "params": {
      "text": "Hello, København 👋",
      "encoding": "base64",
      "padding": true
    },
    "generatedAt": "2026-07-30T15:14:08.000Z"
  }
}
Unpadded base64url
GET /api/base-encodings/encode?text=randomapi.dev&encoding=base64url&padding=false
{
  "data": {
    "input": "randomapi.dev",
    "encoding": "base64url",
    "output": "cmFuZG9tYXBpLmRldg",
    "bytes": 13,
    "padded": false
  },
  "meta": {
    "endpoint": "base-encodings",
    "route": "/encode",
    "params": {
      "text": "randomapi.dev",
      "encoding": "base64url",
      "padding": false
    },
    "generatedAt": "2026-07-30T15:14:08.000Z"
  }
}
Uppercase hexadecimal UTF-8 bytes
GET /api/base-encodings/encode?text=Hello&encoding=base16
{
  "data": {
    "input": "Hello",
    "encoding": "base16",
    "output": "48656C6C6F",
    "bytes": 5,
    "padded": false
  },
  "meta": {
    "endpoint": "base-encodings",
    "route": "/encode",
    "params": {
      "text": "Hello",
      "encoding": "base16",
      "padding": true
    },
    "generatedAt": "2026-07-30T15:14:08.000Z",
    "warnings": [
      "'padding' is not applicable to base16 — hexadecimal encoding never uses '=' padding."
    ]
  }
}

GET /api/base-encodings/decode

Live requestRuns against the public API
No key required
GET/api/base-encodings/decode?value=SGVsbG8sIEvDuGJlbmhhdm4g8J%2BRiw%3D%3D&encoding=base64

Request parameters

Encoded value to validate and decode exactly (1–8,192 characters); surrounding whitespace is invalid, not silently trimmed.

RFC 4648 alphabet to use: hexadecimal base16, base32, standard base64, or URL-safe base64url.

Return decoded UTF-8 text, or an integer array for arbitrary binary bytes.

Advanced response options4 options

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

Return all fields except these (comma-separated).

Pretty-print the JSON response.

Drop the envelope: return the raw array/object without data/meta wrapper.

Response

Example parameters are ready. Send the request to inspect the live response.

Route reference

Code samples Ready-to-copy requests in 4 languages
Choose a code sample language
curl "https://randomapi.dev/api/base-encodings/decode?value=SGVsbG8sIEvDuGJlbmhhdm4g8J%2BRiw%3D%3D&encoding=base64"
const res = await fetch("https://randomapi.dev/api/base-encodings/decode?value=SGVsbG8sIEvDuGJlbmhhdm4g8J%2BRiw%3D%3D&encoding=base64");
const { data, meta } = await res.json();
import requests

data = requests.get("https://randomapi.dev/api/base-encodings/decode?value=SGVsbG8sIEvDuGJlbmhhdm4g8J%2BRiw%3D%3D&encoding=base64").json()["data"]
$json = json_decode(file_get_contents(
  "https://randomapi.dev/api/base-encodings/decode?value=SGVsbG8sIEvDuGJlbmhhdm4g8J%2BRiw%3D%3D&encoding=base64"
), true);
$data = $json["data"];
Parameters Route-specific request inputs 3
value string required

Encoded value to validate and decode exactly (1–8,192 characters); surrounding whitespace is invalid, not silently trimmed.

allowed: 1 – 8192
example: value=SGVsbG8sIEvDuGJlbmhhdm4g8J-Riw==
encoding enum

RFC 4648 alphabet to use: hexadecimal base16, base32, standard base64, or URL-safe base64url.

default: base64
allowed: base16 | base32 | base64 | base64url
example: encoding=base64url
output enum

Return decoded UTF-8 text, or an integer array for arbitrary binary bytes.

default: text
allowed: text | bytes
example: output=bytes
Universal parameters Shared response and formatting options 4
fields list

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

example: fields=input,encoding
exclude list

Return all fields except these (comma-separated).

example: exclude=padded
pretty boolean

Pretty-print the JSON response.

default: false
example: pretty=true
unwrap boolean

Drop the envelope: return the raw array/object without data/meta wrapper.

default: false
example: unwrap=true
Response schema Fields returned in each record 6
input string

Validated encoded input.

example: SGVsbG8=

encoding string

Selected RFC 4648 encoding.

example: base64

output string | integer[]

Decoded UTF-8 text or byte array, according to the output parameter.

example: Hello

bytes integer

Number of decoded bytes.

example: 5

validUtf8 boolean

Whether decoded bytes are well-formed UTF-8.

example: true

padded boolean

Whether the input used trailing '=' padding.

example: true

Documented examples

Build-generated requests and complete responses
3
Decode base64 to Unicode text
GET /api/base-encodings/decode?value=SGVsbG8sIEvDuGJlbmhhdm4g8J%2BRiw%3D%3D&encoding=base64
{
  "data": {
    "input": "SGVsbG8sIEvDuGJlbmhhdm4g8J+Riw==",
    "encoding": "base64",
    "output": "Hello, København 👋",
    "bytes": 22,
    "validUtf8": true,
    "padded": true
  },
  "meta": {
    "endpoint": "base-encodings",
    "route": "/decode",
    "params": {
      "value": "SGVsbG8sIEvDuGJlbmhhdm4g8J+Riw==",
      "encoding": "base64",
      "output": "text"
    },
    "generatedAt": "2026-07-30T15:14:08.000Z"
  }
}
Decode unpadded base32
GET /api/base-encodings/decode?value=JBSWY3DPEBLW64TMMQ&encoding=base32
{
  "data": {
    "input": "JBSWY3DPEBLW64TMMQ",
    "encoding": "base32",
    "output": "Hello World",
    "bytes": 11,
    "validUtf8": true,
    "padded": false
  },
  "meta": {
    "endpoint": "base-encodings",
    "route": "/decode",
    "params": {
      "value": "JBSWY3DPEBLW64TMMQ",
      "encoding": "base32",
      "output": "text"
    },
    "generatedAt": "2026-07-30T15:14:08.000Z"
  }
}
Inspect arbitrary bytes
GET /api/base-encodings/decode?value=__79&encoding=base64url&output=bytes
{
  "data": {
    "input": "__79",
    "encoding": "base64url",
    "output": [
      255,
      254,
      253
    ],
    "bytes": 3,
    "validUtf8": false,
    "padded": false
  },
  "meta": {
    "endpoint": "base-encodings",
    "route": "/decode",
    "params": {
      "value": "__79",
      "encoding": "base64url",
      "output": "bytes"
    },
    "generatedAt": "2026-07-30T15:14:08.000Z"
  }
}

About this API

Coverage & behavior

Encodes Unicode text to bytes with UTF-8 and converts those bytes using the exact RFC 4648 alphabets for base16, base32, base64 or URL-safe base64url. The reverse route validates before it decodes: malformed alphabets, impossible lengths, misplaced padding and non-zero unused bits return a clear 400 rather than being silently repaired.

  • /encode accepts text and returns the encoded string plus its UTF-8 byte count. padding=true (the default) emits canonical = padding for base32/base64/base64url; base16 never has padding and reports padded=false.
  • /decode accepts padded or canonical unpadded input. output=text (default) requires valid UTF-8; use output=bytes for arbitrary binary data, returned as an integer array. validUtf8 tells you whether those bytes form well-formed UTF-8.

This is deterministic conversion, not encryption, hashing or secret storage. Inputs are bounded (4,096 text characters or 8,192 encoded characters) so a public Worker cannot be turned into an unbounded transcoder. For randomly generated fake credentials, use the Tokens API instead.

Use it for

  • Encode Unicode test strings for HTTP Basic, data formats and fixture files
  • Decode JWT-style base64url segments while keeping binary output available
  • Reject malformed or non-canonical base encodings in validation tests

Frequently asked questions

Does it support Unicode text?

Yes. Text is converted to and from UTF-8 bytes, so emoji and non-Latin scripts round-trip correctly.

What's the difference between base64 and base64url?

Base64 uses + and /; base64url replaces them with URL-safe - and _. Both can be emitted padded or unpadded.

Will the decoder accept malformed input?

No. It rejects wrong alphabets, impossible lengths, bad padding and non-canonical unused bits with a 400 instead of guessing.

Is base64 encryption?

No. Every supported format is a reversible byte encoding and provides no confidentiality or integrity.

Standards & references