Snipget.ai

Encoding html entities

Exact
encoding_html_entities

Deterministic and authoritative — the canonical answer for this input.

Escape or unescape HTML entities. mode='encode' (escape) or 'decode' (unescape); on encode, quote also escapes quotes (attribute-safe). Distinct from text_html_strip, which removes tags entirely. Processing multiple inputs? Use `encoding_html_entities_batch` to do up to 1000 in one call.

Parameters

valuestringrequired

Text to escape, or HTML with entities to unescape.

modestringoptional

'encode' (escape) or 'decode' (unescape).

quotebooleanoptional

On encode, also escape quotes (attribute-safe).

Call it

curl -X POST https://api.snipget.ai/v1/encoding/html-entities \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"value":"<b>","mode":"encode"}'

The Batch tab sends up to 1000 inputs in one call via /v1/encoding/html-entities/batch.

Example response

{
  "input": "<b>",
  "is_valid": true,
  "mode": "encode",
  "output": "&lt;b&gt;"
}

FAQ

Why would I escape HTML entities?

When you put user text on a web page, characters like <, >, and & can break the layout or open a security hole. Escaping turns them into safe codes like &lt; and &gt; so they display as plain text instead of being treated as code.

Does it also undo the escaping?

Yes. Set mode to 'encode' to make text safe, or 'decode' to turn entities like &amp; back into the original & characters.

What does the quote option do?

On encode, quote (on by default) also escapes single and double quotes, which makes the result safe to drop inside an HTML attribute. Turn it off if you only want angle brackets and ampersands handled.

How is this different from the HTML strip tool?

This one keeps your tags but makes them safe to display, converting < into &lt;. The separate text_html_strip tool does the opposite: it removes tags entirely and leaves just the plain text.

Is the output exact?

Yes. Escaping is an exact, deterministic operation, so the result is the canonical one and identical on every call.

Related tools