- When do I need to HTML-encode text?
- Whenever user-provided text is inserted into HTML without a templating engine. Encoding prevents XSS: `<script>` becomes `<script>` and renders as visible text.
- Which characters get encoded?
- The five dangerous ones: &, <, >, ", '. Toggle 'aggressive' to also encode non-ASCII characters as numeric entities for maximum portability.
- Should I use this or my framework's escape function?
- Always prefer the framework (React's default, Vue's {{ }}, Angular's interpolation). This tool is for raw HTML contexts — emails, static files, one-off patches.
- Does it encode newlines?
- No — `\n` isn't dangerous in HTML. If you need to convert newlines to `<br>`, use a separate nl2br helper. Encoding is about escaping, not formatting.