Escape and unescape text

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

Input

The text to escape or unescape.
What the text is being prepared for.
Escape plain text, or turn escaped text back into plain text.

Result

Fill in the input and press Run.

Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.

Use it from code or an agent

curl -s https://setget.net/v1/tools/escape-unescape \
  -H 'Content-Type: application/json' \
  -d '{"input":{"text":"<a href=\"x\">Tom & Jerry</a>","format":"html"}}'
import json, urllib.request

body = {'input': {'text': '<a href="x">Tom & Jerry</a>', 'format': 'html'}}
request = urllib.request.Request("https://setget.net/v1/tools/escape-unescape", json.dumps(body).encode(),
                                 {"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/escape-unescape", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"text":"<a href=\"x\">Tom & Jerry</a>","format":"html"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "escape-unescape",
  "input": {
    "text": "<a href=\"x\">Tom & Jerry</a>",
    "format": "html"
  }
}
{
  "input": {
    "text": "<a href=\"x\">Tom & Jerry</a>",
    "format": "html"
  }
}

Endpoint: POST /v1/tools/escape-unescape. Over MCP: run_tool with slug: "escape-unescape". Machine-readable: input schema, Markdown. Connect an agent.

Inputs

NameTypeRequiredWhat it does
text string yes The text to escape or unescape.
format string yes What the text is being prepared for. One of: html, url, json, shell, regex, csv.
direction string no Escape plain text, or turn escaped text back into plain text. One of: escape, unescape. Default: "escape".

Examples

Input
{
  "text": "<a href=\"x\">Tom & Jerry</a>",
  "format": "html"
}
Result
{
  "text": "&lt;a href=&quot;x&quot;&gt;Tom &amp; Jerry&lt;/a&gt;"
}

Decoding a URL

Input
{
  "text": "caf%C3%A9%20au%20lait",
  "format": "url",
  "direction": "unescape"
}
Result
{
  "text": "café au lait"
}

Quoting for a POSIX shell

Input
{
  "text": "it's here",
  "format": "shell"
}
Result
{
  "text": "'it'\"'\"'s here'"
}

A JSON string literal

Input
{
  "text": "Line 1\nSay \"hi\"",
  "format": "json"
}
Result
{
  "text": "\"Line 1\\nSay \\\"hi\\\"\""
}

Questions

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".