# Escape and unescape text

Escape or unescape text for HTML, URLs, JSON strings, shell commands, regular expressions and CSV fields.

- Endpoint: `POST https://setget.net/v1/tools/escape-unescape` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `escape-unescape`
- Page: https://setget.net/tools/escape-unescape

## Inputs

- `text` (required, string): The text to escape or unescape.
- `format` (required, string, one of `html`, `url`, `json`, `shell`, `regex`, `csv`): What the text is being prepared for.
- `direction` (optional, string, one of `escape`, `unescape`, default `"escape"`): Escape plain text, or turn escaped text back into plain text.

## Example 1

```json
{"input":{"text":"<a href=\"x\">Tom & Jerry</a>","format":"html"}}
```

Result:

```json
{"text":"&lt;a href=&quot;x&quot;&gt;Tom &amp; Jerry&lt;/a&gt;"}
```

## Example 2: Decoding a URL

```json
{"input":{"text":"caf%C3%A9%20au%20lait","format":"url","direction":"unescape"}}
```

Result:

```json
{"text":"café au lait"}
```

## Example 3: Quoting for a POSIX shell

```json
{"input":{"text":"it's here","format":"shell"}}
```

Result:

```json
{"text":"'it'\"'\"'s here'"}
```

## Example 4: A JSON string literal

```json
{"input":{"text":"Line 1\nSay \"hi\"","format":"json"}}
```

Result:

```json
{"text":"\"Line 1\\nSay \\\"hi\\\"\""}
```

**Which shells does the shell format suit?** POSIX shells such as sh, bash and zsh. It is not correct for Windows cmd or PowerShell.

**Does URL unescape turn "+" into a space?** No. "+" only means a space in form data. Here it stays a plus sign; "%20" becomes a space.

**Does JSON escape include the surrounding quotes?** Yes, the result is a complete JSON string. Unescape accepts the text with or without them.

**What does shell unescape return for several words?** The words are returned separately in "words", and joined by single spaces in "text".
