Prompt & Context Cleaner
Sanitize prompts, mask PII (emails, cards, IPs), strip HTML and comments, and optimize context sizes.
Runs in your browser. Nothing you add is uploaded.
What the Prompt & Context Cleaner does
Paste text you are about to give an AI model, such as a scraped web page, a log file, documentation or source code, and this tool removes what wastes tokens or should not leave your hands: HTML tags, code comments, Markdown formatting and runs of blank lines. It can also mask email addresses, phone numbers, IPv4 addresses, card-number patterns and AWS access key IDs with placeholders like [EMAIL_REDACTED]. Each step is a switch, a counter shows the characters and estimated tokens saved, and everything runs in the browser, so the unredacted text never leaves your device.
How to clean and redact text for an AI model
- Paste your text, or load a sample: a scraped HTML page, heavily commented code, or Markdown with personal data.
- Switch the steps on or off: Strip HTML / XML Tags, Mask PII & Secrets, Strip Code Comments, Strip Markdown Syntax and Collapse Blank Lines.
- Compare input and output side by side, and read the tokens saved and the size reduction.
- Read through the output, then copy it.
The Prompt & Context Cleaner runs entirely in your browser — nothing you enter is uploaded, stored, or logged.
When to use it
Sharing logs with an AI assistant
Application logs routinely contain customer email addresses, IP addresses and phone numbers. Masking them before pasting into a chat or an API call keeps that data out of the provider's systems while leaving the shape of the error intact, so the model can still help diagnose it.
Cleaning scraped pages for retrieval (RAG)
HTML scraped from documentation is mostly tags and attributes. Stripping them and collapsing blank lines before splitting text into chunks for embedding means each chunk carries more real content, and the index costs less to build and store.
Fitting code into a context window
Licence headers, commented-out code and long doc comments can be a large share of a source file. Removing them before asking for a review or refactor leaves more room for the code itself; keep comments that explain intent the model needs to understand.
Good to know
- Redaction is pattern-based. It catches common email formats; phone numbers written with a + country code, Indian mobile numbers and North American 10-digit numbers; IPv4 addresses; 16-digit card numbers; and AWS key IDs starting with AKIA. Names, street addresses, IPv6 addresses and most other secrets are not detected, so read the output before sending it.
- Long digit strings such as 11-digit order numbers can be masked as phone numbers. Over-masking is the safer mistake, but check that nothing you need was replaced.
- Comment stripping removes // comments and # comments that start a line or follow a space, so prose containing // or a line beginning with '# ' loses text too. Switch it off for plain prose. Shebang lines (#!) are kept.
- With Strip Markdown on, headings keep their text and only the # markers go; underscores inside names like user_id are left alone.
- Tokens saved is an estimate (characters ÷ 4), good for comparing before and after.
Frequently asked questions
Why should I clean context before sending it to an LLM?
Does this tool work completely offline?
Does stripping Markdown hurt the model's understanding?
Is the redacted text safe to share?
Page last updated . Found a wrong result or a mistake on this page? Let us know.
Related tools
AI Code & Formula Explainer
Plain-English explanations of formulas, calculations and code.
Optional cloud mode
AI Text Rewriter
Rewrite text in a professional, friendly, concise or formal tone.
Optional cloud mode