consolelog.tools

XSS Detector

Scan user input or HTML for Cross-Site Scripting vectors — script tags, inline event handlers, javascript:/data: URIs, SVG and CSS vectors, DOM sinks, and encoded payloads — each graded by severity with a line/column location and a fix. Then see your input correctly encoded for any output context (HTML, attribute, JS, URL, CSS), with framework-safe output snippets. Switch to Reference mode for a categorized payload + encoding cheat-sheet.

About this ToolHow it works, benefits & use cases

A two-in-one Cross-Site Scripting toolkit. In Scan mode you paste user input or an HTML fragment and the detector matches it against categorized XSS vectors — script tags, inline event handlers (onerror, onload, onclick, ...), javascript: and vbscript: URIs, data:text/html payloads, SVG vectors (embedded scripts, animate handlers, foreignObject), CSS vectors (expression(), url(javascript:), @import), DOM sinks (innerHTML, document.write, eval, string-argument timers), dangerous elements (iframe, object, embed, base, meta-refresh, form action), and encoded or obfuscated forms (HTML entities, URL-percent, unicode and hex escapes). Each finding reports its category, a severity badge (critical, high, medium, low), the matched snippet, and the exact line and column, and the results roll up into per-severity counts. Below that, a context-aware encoder shows your input correctly escaped for HTML body, HTML attribute, JavaScript string, URL, or CSS contexts, side by side with the raw input, plus framework-safe output snippets for React/JSX, vanilla DOM textContent, a DOMPurify allowlist config, and a server-side note. Reference mode is a categorized payload and encoding cheat-sheet: every entry pairs a representative payload with what it exploits and how to fix it, followed by an output-encoding rules table. Everything runs locally in your browser and the tool never injects any payload into the page — every snippet is rendered as escaped text.

How to Use

  1. 1In Scan mode, paste the text or HTML you want to check, or click Load example.
  2. 2Click Scan for XSS to get categorized findings with severity, line/column, and a fix for each.
  3. 3Pick an output context (HTML body, attribute, JS string, URL, or CSS) to see your input correctly encoded side by side with the raw input.
  4. 4Review the framework-safe output snippets (React, DOM textContent, DOMPurify, server-side) and apply them.
  5. 5Switch to Reference mode for a categorized payload-and-fix cheat-sheet plus an output-encoding rules table.

Key Benefits

  • Categorized detection across nine vector families, each finding graded by severity
  • Line and column location plus a concrete fix for every match
  • Context-aware encoder: HTML body, attribute, JS string, URL, and CSS encodings
  • Framework-safe output examples for React, vanilla DOM, DOMPurify, and the server
  • Reference cheat-sheet pairing real payloads with what they exploit and how to fix them
  • Runs entirely in the browser and never injects payloads — snippets are shown as escaped text

Common Use Cases

  • Triaging a suspected payload from a bug report or pentest finding
  • Sanity-checking user-supplied HTML before rendering it in an app
  • Picking the correct output encoding for the context a value lands in
  • Teaching a team which HTML, URL, and DOM constructs are dangerous and why
  • Spotting encoded or obfuscated injection attempts during code review

Paste user-supplied input or an HTML fragment. Everything runs locally in your browser.

About Cross-Site Scripting (XSS)

XSS attacks inject malicious scripts into web pages viewed by other users

Stored XSS

Malicious script is permanently stored on the server (e.g., in a database)

Reflected XSS

Malicious script is reflected off a web server (e.g., in URL parameters)

DOM-based XSS

Vulnerability exists in client-side code rather than server-side

This is a defensive, educational aid — a clean result is not a guarantee of safety. Always combine framework auto-escaping, contextual output encoding, a strong CSP, and server-side validation.

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related tools