NewAPIVerve Academy: free courses and certifications anyone can verify.Explore the Academy →

HTML Entities Encoder/Decoder API

POST

Neutralize unsafe characters in HTML to prevent XSS attacks.

HTML Entities Encoder/Decoder converts special characters into safe HTML entities or restores encoded strings back to standard text. Pass any HTML markup or text snippet to receive the converted string, a replacement count, and a list of modified characters.

Try it — live request, no key required

Request
POSTapi.apiverve.com/v1/htmlentities
Body
Verification
Format

No key required to try it. Get a key to use it in your app.

Example
{
  "status": "ok",
  "error": null,
  "data": {
    "action": "encode",
    "original": "<div class=\"test\">Hello & World</div>",
    "encoded": "&lt;div class=&quot;test&quot;&gt;Hello &amp; World&lt;&#x2F;div&gt;",
    "entities_replaced": [
      "<",
      "\"",
      ">",
      "&",
      "/"
    ],
    "count": 8
  }
}

About the HTML Entities Encoder/Decoder API

An HTML entities encoder and decoder for making text safe to drop into a page, or for reading encoded markup back as plain characters. Set action to encode for HTML encode (escape) or decode for HTML decode (unescape), POST the string, and get back the converted text with a count of replacements and a list of which characters or entities were involved.

Escaping the characters that carry meaning in HTML is a basic step in XSS prevention when user input ends up in templates, emails or admin screens. The decode direction helps when scraped content, RSS feeds or database exports arrive full of &lt; and &quot; sequences that need to be shown or searched as normal text.

There is no plan difference here: the Free plan and paid plans run the same conversion and return the same fields.

How it works

Encoding replaces six characters with entities: & becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot;, ' becomes &#39; and / becomes &#x2F;. Nothing else is touched, so accented letters, emoji and other non-ASCII text pass through unchanged. count is the total number of replacements and entities_replaced lists each distinct character that was replaced, in order of first appearance; the escaped string is returned in encoded.

Decoding first replaces the named forms &amp;, &lt;, &gt;, &quot;, &#39;, &#x2F; and &apos;, then any decimal (&#123;) or hexadecimal (&#x7B;) numeric reference. The result is returned in decoded, and entities_decoded lists the named entities found plus the markers &#numeric; and &#xhex; when numeric references were present. Other named entities such as &nbsp; or &copy; are left as they are.

Two details matter for decode. &amp; is processed before the others, so a double-encoded sequence like &amp;lt; is decoded all the way to < in one call. Numeric references are converted with 16-bit character codes, so references above U+FFFF (most emoji) do not come back as the intended character. Any value other than decode for action is treated as encode.

What people use it for

XSS Prevention
Encode user input before displaying in HTML to prevent cross-site scripting (XSS) attacks
Data Display
Decode HTML entities in stored content to display special characters correctly in web applications
Content Migration
Encode or decode HTML entities when migrating content between systems with different encoding requirements
API Integration
Properly encode HTML content before sending to APIs or decode entities received from external sources

Ways to call it

One endpoint, many ways in — REST with JSON, XML, YAML and CSV, plus GraphQL and an MCP interface for AI agents.

JSON
Default REST response
XML
Markup format
YAML
Human-readable
CSV
Tabular export
Beta
GraphQL
Query language
New
MCP
For AI agents

Other ways to use HTML Entities Encoder/Decoder

Same data, same APIVerve account, same credit balance — one key works on all of them.

Questions.

Common questions about the HTML Entities Encoder/Decoder API.

Read the docs →
Which characters does the API escape when encoding?
It converts characters like angle brackets, ampersands, quotation marks, and slashes into their standard HTML entity equivalents. This ensures user-supplied text can be displayed safely in browsers without being interpreted as executable markup.
Can I convert HTML entities back into plain characters?
Yes. The Decode HTML Entities endpoint reverses the transformation, converting entity representations back to their original special characters for editing, content migration, or downstream data processing.
Does the response show which characters were modified?
Yes. Every response includes a list of all characters or entity patterns replaced during the call, as well as a count of the total replacements made in your text.
Can I view the original text alongside the converted result?
Yes. Each response returns both the original input string and the resulting transformed string, allowing you to easily verify changes without retaining separate state in your code.
What would encoding 50,000 text snippets a month cost me?
That volume fits comfortably within the Starter plan at $29.99 per month. Each call uses 1 credit, so Starter covers up to 200,000 calls monthly, working out to about $0.15 per 1,000 calls. You can also test with 200 calls per month on the Free plan.

Ready to build with HTML Entities Encoder/Decoder? Start with 200 free credits — one key unlocks all 300+ APIs.

Explore the catalog

300+ APIs on the same key and the same response shape.

Browse all APIs