XSS Payload Encoder
Encode and decode XSS payloads for authorized security testing. HTML entities, URL, Base64, Unicode, hex, and double encoding.
Understanding XSS Attack Types
Reflected XSS
The malicious script is included in a request (URL, form) and reflected back in the immediate response. The victim must click a crafted link. Not stored on the server.
Stored XSS
The payload is saved on the server (database, comment, profile) and executed whenever any user loads the affected page. More dangerous — no crafted link needed.
DOM-Based XSS
The vulnerability is in client-side JavaScript. The payload modifies the DOM without ever hitting the server. Common in innerHTML, document.write, and eval sinks.
How to Use the XSS Payload Encoder
- Select a test payload from the quick-load chips, or type your own payload in the input area.
- Choose Encode or Decode using the mode chips above the input.
- Review all encodings — the tool produces HTML entity, URL, Base64, Unicode escape, hex escape, and double-encoded variants simultaneously.
- Copy individual encodings using the Copy button on each row, then test them in your authorized target application.
Encoding Methods Explained
- HTML Entities — Converts characters like
<>&"to their HTML entity equivalents (<etc.). Useful for testing context-aware output encoding. - URL Encoding (percent encoding) — Converts characters to their %XX hexadecimal representation. Essential for payloads injected into URL parameters, query strings, or path segments.
- Base64 — Encodes the payload as Base64. Used with
eval(atob(...))ordata:URIs to bypass string-matching filters. - Unicode Escapes — Converts characters to
\uXXXXnotation. JavaScript interprets these natively, allowing script injection through Unicode-unaware filters. - Hex Escapes — Converts characters to
\xXXhexadecimal notation, another form recognized by JavaScript engines. - Double Encoding — Applies URL encoding twice. Some vulnerable applications decode input twice (e.g., in a WAF and then in the application), allowing double-encoded payloads to slip through.
Common XSS Filter Bypass Techniques
Security researchers and penetration testers use encoding to test whether an application's input sanitization is complete. A well-implemented application should reject or neutralize all of these variants. If one encoding slips through, it indicates the application is only checking for specific patterns rather than performing proper context-aware output encoding. The gold standard for XSS prevention is to encode output at render time, not just validate input — because what constitutes "valid" depends entirely on the context where the data will be used.
When testing for XSS, always start with the simplest payload: <script>alert(1)</script>. If that fails, try event handlers like <img src=x onerror=alert(1)>. If those fail, try encoding variants. If all fail, the application is likely properly escaping output. Document every test and result for your penetration testing report.
Responsible Disclosure
If you discover a real XSS vulnerability during authorized testing, follow responsible disclosure practices: report the vulnerability privately to the organization's security team or via their bug bounty program (HackerOne, Bugcrowd, etc.), give them a reasonable remediation window (typically 90 days), and work collaboratively to verify the fix before public disclosure. Do not publish proof-of-concept exploits targeting real users without coordination. This protects both users and maintains the trust that makes bug bounty programs viable.
XSS Prevention Checklist for Developers
- Use a modern framework (React, Angular, Vue) that auto-escapes template output
- Never use
innerHTML,document.write, orevalwith user-supplied data - Implement a strict Content Security Policy (CSP) —
Content-Security-Policy: default-src 'self' - Set
HttpOnlyandSecureflags on session cookies - Use the
SameSitecookie attribute to mitigate CSRF alongside XSS - Validate input type/format on the server side — but rely on output encoding as the primary defense
- Audit third-party scripts — any script on your page can steal user data
Frequently Asked Questions
< becomes %3C then %253C. Some vulnerable systems (especially WAF + application combos) decode input twice: the WAF decodes once (sees %3C, still encoded), then the application decodes again (sees the raw <). This allows the payload to bypass the WAF's check.