# Encode HTML for safe display

> Convert characters such as , &, quotes, and apostrophes into HTML entities on the server.

Canonical: https://staticx.site/html-encode

## Display HTML as text

Encode angle brackets, ampersands, quotes, and apostrophes before placing snippets inside documentation, examples, or CMS fields.

## Avoid accidental rendering

Encoded snippets remain readable without turning into active tags or breaking the surrounding page.

## Useful before publishing docs

Use the output in StaticX documentation pages, code examples, changelog entries, or agent instructions.

## How to use HTML Encode

Escape markup before it is shown as documentation, examples, or inline teaching material.

1. **Paste the snippet** — Add the HTML or text that needs to be displayed literally.
2. **Encode entities** — Submit it to StaticX and review the escaped output returned by the server.
3. **Copy into your page** — Place the encoded result inside your static page, docs block, or template.

## HTML encoding protects the page around your snippet.

If a tutorial needs to show a form, script tag, or layout fragment, raw HTML can be interpreted by the browser instead of shown to the reader.

Encoding converts special characters into entities so the snippet stays visible and the rest of the static page remains structurally intact.

## Where encoded HTML belongs

- **Good for examples** — Show form markup, MCP snippets, or template fragments without creating real elements.
- **Not a sanitizer** — Encoding is for display. It is not a full security sanitizer for untrusted rich content.
- **Review before release** — Paste the encoded result into the page and preview before publishing a new StaticX version.

## FAQ

### What characters does HTML encoding change?

It converts characters such as , &, quotes, and apostrophes into safe HTML entities.

### Should I encode form code before using it?

Only encode form code when you want to display it as an example. Do not encode form markup that should actually submit.

### Can encoding fix unsafe user content?

Encoding helps display text safely, but it is not a complete content moderation or sanitization system.

[View on staticx.site](https://staticx.site/html-encode)
