XRazor is a tool for cleaning web artifacts into AI-readable context.
It currently supports:
- HTML cleaning
- HAR cleaning
- AI-friendly context export
XRazor turns noisy web files into input that is easier for AI to understand.
Common use cases:
- simplify saved HTML or browser DOM snapshots
- reduce HAR files to the requests and responses that matter
- generate a quick page or API summary for AI workflows
.html.htm.har
python -m pip install -e .The browser-friendly TypeScript core is available under packages/core:
npm installimport { cleanHtmlText, cleanHar } from "@xrazor/core";
const htmlResult = cleanHtmlText(html);
const harResult = cleanHar(JSON.parse(harText));The Python and TypeScript implementations are maintained as separate runtimes. They share the same cleaning rules and are intended for different integration scenarios.
Build the browser distributions with:
npm run build:browserThis produces:
packages/core/dist/index.js # ES module
packages/core/dist/index.global.js # IIFE browser bundle
packages/core/dist/index.d.ts # Type declarations
The IIFE bundle exposes the API as window.XRazor:
<script src="./packages/core/dist/index.global.js"></script>
<script>
const result = XRazor.cleanHar({ log: { entries: [] } });
</script>cleanHar and cleanHarText are pure JavaScript and work in browsers, Web Workers, and Node.js. cleanHtmlText requires a browser DOM environment providing DOMParser, NodeFilter, and XMLSerializer. For an existing page DOM, use cleanHtmlDocument(document).
Run the JavaScript checks locally with:
npm ci
npm run typecheck:js
npm run test:js
npm run build:browser
npm run test:browser-bundle
npx playwright install chromium
npm run test:real-browserThe Python implementation remains independently testable:
python -m pytest -qBefore publishing @xrazor/core, inspect the package contents with:
Push-Location packages/core
npm pack --dry-run
Pop-LocationThe current package version is @xrazor/core@0.1.1. Downstream applications should use this released version once published, or pin a specific commit while release packaging is being prepared. They should not follow main directly.
Run commands with either python -m xrazor or xrazor.
python -m xrazor clean tt_page.html --out cleaned.htmlpython -m xrazor clean item_list.har --out cleaned.har.jsonpython -m xrazor export tt_page.html --format json
python -m xrazor export tt_page.html --format markdown
python -m xrazor export item_list.har --format json
python -m xrazor export item_list.har --format markdownpython -m xrazor context tt_page.html
python -m xrazor context item_list.harXRazor is designed for AI readability, not browser replay.
- non-essential content may be removed
- useful structure is kept where possible
- replaced values use stable
[xrazor]...placeholders
Example placeholders:
[xrazor]filtered-base64-content[xrazor]trimmed-long-text[xrazor]removed-binary-content
- cleaner HTML structure
- smaller and more useful HAR output
- faster AI understanding of page structure and API activity