A categorized reference of cross-site scripting payloads for authorized testing, filter evaluation, and detection.
Use responsibly — authorized testing only. Use this tool only on systems you own, a written engagement with a defined scope, or a lab or CTF you are allowed to attack. Keep that written permission next to your notes before you start. Unauthorized access is illegal in most jurisdictions — legal responsibility for what you run sits with you, not with this page. The tool is provided as-is, with no warranty.
Cross-site scripting (XSS) is the injection of attacker-controlled script into a page that other users' browsers then execute, in the victim's session and origin. This reference groups the classic, well-documented payloads by the context they target, because the single most important fact about XSS is that the right payload — and the right defense — depends entirely on where the input lands.
Context is everything. In an HTML body, <script>alert(1)</script> or <img src=x onerror=alert(1)> works. Inside an HTML attribute, you must first break out of the quotes (" onmouseover="alert(1)). Inside an existing JavaScript string, you break out of the string or the script block instead. Filter-bypass variants use event handlers without <script>, template literals to avoid parentheses, the javascript: URI scheme, or entity-encoded nesting to evade naive blocklists.
How you'll use it. Pick a context to see representative payloads with a note on each. Use them to confirm a reflected or stored XSS on a target you are authorized to test, to evaluate whether an input filter or WAF actually holds, and to build detections. The categorization doubles as a teaching aid for why a filter that strips <script> still fails against an onerror handler.
Types of XSS. Reflected XSS bounces off a request parameter; stored XSS persists in the database and hits every viewer; DOM-based XSS never touches the server, arising when client-side JavaScript writes untrusted data into a sink like innerHTML. Each needs the same contextual thinking. Stored XSS is the most damaging of the three because a single injected payload executes in the session of everyone who loads the affected page — including administrators — which is how an XSS bug escalates into full account or application takeover.
Why a blocklist fails. The recurring lesson of this reference is that stripping the string <script> is not a defense. The same effect is reachable through <img onerror>, <svg onload>, <body onpageshow>, the javascript: URI scheme, and dozens more vectors, many of which need no angle brackets at all once you are inside an attribute or a script context. Any filter that enumerates bad patterns is playing a game it cannot win; encoding the output for its context is the move that closes every variant at once.
Defensive angle — the real fixes. Contextual output encoding is primary: HTML-encode for body/attributes, JavaScript-encode for script contexts, URL-encode for URLs. Prefer frameworks that auto-escape (React, modern templates) and treat innerHTML/dangerouslySetInnerHTML as reviewed exceptions. Layer a strict Content-Security-Policy (nonce/hash-based, no unsafe-inline) so a missed escape does not become code execution — grade yours with the security header analyzer — set HttpOnly on session cookies to blunt token theft, and sanitize rich HTML with a vetted library like DOMPurify rather than a homemade blocklist.
Usage notes (authorized testing). Browse the canonical payloads by context only against apps you own, a written penetration-test scope, a bug-bounty program that allows the test, or a local lab; written permission and a defined scope come first. Confirm the injection point and the response context (HTML body, attribute, JavaScript string, URL) are in scope, pick the category that matches that context — basic proof, attribute breakout, JavaScript-string breakout, or filter-bypass variants (the same well-known strings scanners and WAFs already list) — and use a payload to confirm a reflected or stored finding or to prove a filter or WAF rule fails, adapting quoting to the real sink; this page does not invent new exploit chains. Prefer a local lab when you are learning, and when the same input also reaches a SQL query, pair this reference with the SQL injection payload reference. Updated October 18, 2026.
Detection & Defense. The primary fix is contextual output encoding — HTML-encode for body and attributes, JavaScript-encode for script contexts, URL-encode for URLs; prefer frameworks that auto-escape and treat innerHTML and equivalent sinks as reviewed exceptions, sanitising any rich HTML with a vetted library (for example DOMPurify), not a homemade blocklist. Detect by alerting on classic proof-of-concept shapes in request and response logs, on unexpected event-handler attributes in stored content, and on script or SVG markup reaching sinks that should be text-only; feed these reference strings into WAF and CSP tests, then remember encoding and context shifts bypass signature-only rules. The controls that break the technique are a strict Content-Security-Policy (nonce or hash based, no unsafe-inline) so a missed escape does not become code execution, HttpOnly on session cookies to blunt token theft, and grading response headers with the security header analyzer. And the limit: stripping the string "script" is not a defense — the same effect is reachable through image and SVG event handlers, the javascript URI scheme, and vectors that need no angle brackets once you are inside an attribute or a script context, so encoding for the output context closes every variant at once.
Generate copy-ready reverse-shell one-liners for bash, netcat, python, perl, php, ruby and PowerShell — plus the matching listener command. Enter your listener host (LHOST) and port (LPORT), pick a shell, and paste the payload on a system you're authorized to test. Everything runs in your browser; nothing is sent to a server.
A categorized reference of canonical SQL injection payloads for authorized testing and WAF/detection engineering.