---
title: "Use this when you need to encode or decode text and want multi-byte and entity edge cases handled correctly rather than doing it by hand."
method: POST
path: "/v1/encode_decode"
tags: ["developer"]
---

# Use this when you need to encode or decode text and want multi-byte and entity edge cases handled correctly rather than doing it by hand.

`POST /v1/encode_decode`

## Request

- Base URL: `https://api.clean.tools`
- URL: `https://api.clean.tools/v1/encode_decode`
- Auth: none declared

Use this when you need to encode or decode text and want multi-byte and entity edge cases handled correctly rather than doing it by hand. Deterministic: same input, same output. The mode selects the operation: url-encode/url-decode (percent-encoding), html-encode/html-decode (entity table plus numeric character references), base64-encode/base64-decode (UTF-8 safe; decode tolerates URL-safe alphabet, whitespace, and missing padding), and unicode-encode/unicode-decode (\uXXXX and \u{...} escapes for non-ASCII). Every mode returns the same shape: {mode, output}. Example: mode base64-encode, text "héllo" -> output "aMOpbGxv".

## Request body

- object
  - `mode` 'url-encode' | 'url-decode' | 'html-encode' | 'html-decode' | 'base64-encode' | 'base64-decode' | 'unicode-encode' | 'unicode-decode', required: Operation to perform.
  - `text` string, required: Input text.

## Response `200`

Structured tool result.

- object
  - `tool` string
  - `result` object
    - `mode` 'url-encode' | 'url-decode' | 'html-encode' | 'html-decode' | 'base64-encode' | 'base64-decode' | 'unicode-encode' | 'unicode-decode', required: The operation that was performed (echoed back).
    - `output` string, required: The encoded or decoded result string.

## Other responses

- `400`: Invalid input or the tool reported an error.
- `413`: Request body exceeds the 128 KB limit.
- `429`: Rate limit exceeded; the response carries Retry-After and RateLimit-* headers — honor them and add jitter.

---

[API](https://skmtc.dev/clean/apis/clean-tools-api.md) · [All operations](https://skmtc.dev/clean/apis/clean-tools-api/llms.txt) · [OpenAPI document](https://skmtc.dev/clean/apis/clean-tools-api/revisions/a24a01d2833c?raw)
