# Base64url encode

`base64url-encode` · version 1.0.0 · Other utilities · free, no key needed

Encode supplied UTF-8 text or hexadecimal bytes as base64url and return the encoded string.

**Use when you need to: encode text as URL-safe base64 · convert hex bytes to base64url · make base64 safe for a URL.**

## Decide before calling

Read the [versioned contract](/v1/tools/base64url-encode/versions/1.0.0) and the supported scope below. Reuse `base64url-encode@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `base64url-encode@1.0.0` for encode text as URL-safe base64. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- encode text as URL-safe base64
- convert hex bytes to base64url
- make base64 safe for a URL
- base64url encode UTF-8
- encode bytes without base64 padding
- create padded URL-safe base64

## Not supported

- standard base64 with plus and slash
- decode base64url text
- encrypt or sign data

## Behavior

- Exactly one of text or hex is supplied; text is encoded as UTF-8 and hex represents bytes.
- padding true appends RFC 4648 equals padding; padding false omits it.
- Hex input is case-insensitive and must have an even number of digits.
- Disclaimer: format transform only; provides no confidentiality, integrity, or authenticity.

## Input

- `text` (string, optional): max length 12288
- `hex` (string, optional): max length 24576; pattern `^[0-9A-Fa-f]*$`
- `padding` (boolean, required)

## Output

- `encoded` (string, required): max length 16384; pattern `^[A-Za-z0-9_-]*={0,2}$`
- `standard_version` (constant "RFC 4648 §5 (2006); RFC 7515 Appendix C (2015)", required)

## Limits

- max input bytes: 12288
- max output bytes: 16384

## Example

Request input:

```json
{
  "text": "Hello?",
  "padding": false
}
```

Response:

```json
{
  "result": {
    "encoded": "SGVsbG8_",
    "standard_version": "RFC 4648 §5 (2006); RFC 7515 Appendix C (2015)"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "base64url-encode",
  "version": "1.0.0",
  "input": {
    "text": "Hello?",
    "padding": false
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/base64url-encode/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"text":"Hello?","padding":false}'
```

The machine-readable contract is at [/v1/tools/base64url-encode/versions/1.0.0](/v1/tools/base64url-encode/versions/1.0.0).

### CLI

```sh
node cli.mjs run base64url-encode 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Base64url decode](/tools/base64url-decode): Decode base64url to UTF-8 text or lowercase hex and return the requested value.
- [Bytes format human](/tools/bytes-format-human): Format an exact byte count as both SI and IEC strings and return the rounding mode used.
- [Geohash convert](/tools/geohash-convert): Encode decimal coordinates as a bounded Geohash or decode a Geohash to its exact bounding box and midpoint.
- [Base64url validate](/tools/base64url-validate): Check canonical base64url syntax and return validity plus the first invalid character when present.
- [Html to plain text](/tools/html-to-plain-text): Strip HTML and script/style text, decode supported references; collapse whitespace including inside pre elements.
- [Rtf to markdown](/tools/rtf-to-markdown): Convert an 8 KiB ANSI-1252 RTF text subset to escaped Markdown; unsupported Word features are refused.
