Prompt Sanitizer
Strip token-wasting whitespace from system prompts — collapse blank lines, trim trailing spaces, normalise indentation — and see exact tokens saved.
Loading tool controls…
Verify it yourself: press F12, open the Network tab, and use this tool — your files are never uploaded.
Prompt Sanitizer at a glance
- Price
- Free
- Account
- Not required
- File uploads
- None — your files are never uploaded
- Category
- Developer Tools
Who uses Developer Tools?
Developers and engineers formatting JSON, testing regex, hashing data, encoding values or building API requests.
How to Use Prompt Sanitizer
Follow these simple steps to get instant results in your browser.
Paste a System Prompt
Paste the prompt as it is, extra blank lines and all. A messy sample is loaded to try first.
Sanitize
The tool cleans the whitespace and counts tokens before and after.
Copy the Clean Prompt
Copy or download the cleaned prompt and use it in place of the original.
What is Prompt Sanitizer & How Does It Work?
Prompt Sanitizer removes the whitespace that wastes tokens in system prompts: runs of blank lines, trailing spaces, tabs, and ragged common indentation. The words, punctuation and line order are never touched — only whitespace changes.
The savings are measured, not estimated: before and after counts come from js-tiktoken (cl100k_base), the same tokenizer setup as LLM Token Counter, loaded on demand. If the tokenizer cannot load, a character-based estimate is shown and labelled as one.
A typical pasted prompt — copied from a document with double-spaced paragraphs and trailing spaces — often loses a few percent of its tokens for free, on every single request that uses it.
Key Features & Capabilities
Exact Token Counts
Before/after counts from js-tiktoken (cl100k_base), with a labelled estimate only as a fallback.
Whitespace Only
Blank lines, trailing spaces, tabs and common indentation — words are never changed.
Change Log
Each kind of cleanup is listed with how many lines it affected.
Before/After View
See the cleaned prompt next to the exact savings in tokens and characters.
Private by Design
Sanitizing and counting run entirely in your browser. Your prompt is never uploaded.
Pro Tips
- •Bookmark this tool for instant one-click access anytime.
- •Drag and drop files directly onto the input surface for fastest handling.
- •All processing happens in your browser session for maximum speed and data safety.
🎯 Common Use Cases
Prompt Sanitizer - Token Savings
Only whitespace changes — blank-line runs, trailing spaces, tabs and common indentation — so the saving is measured exactly with js-tiktoken before and after, and the same cleaned prompt saves those tokens on every request that uses it.
Worked Example
- 1Sample prompt: 165 characters, 37 tokens
- 2Sanitized: 148 characters, 34 tokens
- 337 − 34 = 3 tokens saved (8.1%); 17 characters removed
Sources & Further Reading
- tiktoken — OpenAI
Frequently Asked Questions about Prompt Sanitizer
Frequently asked questions
More Developer Tools
Complementary utilities for your workflow
Prompt Sanitizer
Clean system prompts and see exact tokens saved.