Encoding Utilities

Html Encode

Converts special characters in text to HTML entities for safe display in web pages. Access via MCP in Cursor or Windsurf, or call GET /v1/encode/html/encode with your text. Transforms `<script>` into `&lt;script&gt;` and handles quotes, ampersands, and other HTML-sensitive characters. Essential for preventing XSS attacks and displaying user content safely.

API Endpoint

GET /v1/encode/html/encode

Code Examples

curl "https://tinyfn.io/v1/encode/html/encode" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/encode/html/encode', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/encode/html/encode',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's encoding tools:

{
  "mcpServers": {
    "tinyfn-encoding": {
      "url": "https://tinyfn.io/mcp/encoding",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

What characters does HTML encoding escape?

Encodes <, >, &, ", and ' into &lt;, &gt;, &amp;, &quot;, and &#x27; respectively. Also handles other special characters that could break HTML structure.

How do I HTML encode text using MCP in my AI coding assistant?

Call the html_encode tool with your text string. Works in Cursor, Claude Code, Copilot, Windsurf, Cline, OpenClaw, and Zed through MCP.

Is HTML encoding the same as URL encoding?

No. HTML encoding escapes characters for safe HTML display (&lt; for <), while URL encoding handles characters for URLs (%20 for spaces).

Does this prevent XSS attacks completely?

HTML encoding is one layer of XSS prevention for displaying user content in HTML. Always combine with proper content security policies and input validation.

What's the difference between encoding quotes as &quot; vs &#x27;?

Both are valid HTML entities. This tool uses &#x27; for single quotes as it works in all contexts, while &apos; has limited XML support.

Try Html Encode Now

Get your free API key and start using Html Encode in seconds.

Get Free API Key