Skip to content

Prompt Sanitizer

Developer Tools•Client-Side & Private

Strip token-wasting whitespace from system prompts — collapse blank lines, trim trailing spaces, normalise indentation — and see exact tokens saved.

Tool workspace

Only whitespace is changed — words, punctuation and line order are never touched. Token counts use js-tiktoken (cl100k_base); if the tokenizer cannot load, a character-based estimate is shown and labelled as an estimate.

Loading tool controls…

Files processed locally — never uploaded to our servers
Free Instant Private

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

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.

1

Paste a System Prompt

Paste the prompt as it is, extra blank lines and all. A messy sample is loaded to try first.

2

Sanitize

The tool cleans the whitespace and counts tokens before and after.

3

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

Cutting API CostsA prompt sent a million times a day saves real money when every wasted token is removed.
Fitting the Context WindowReclaim context space in a long system prompt before adding more instructions or examples.
Cleaning Pasted PromptsFix prompts copied from Word or Google Docs, where blank lines and trailing spaces creep in.
A Shared Team PromptClean the team's shared system prompt once, so every member's requests use the trimmed version and save tokens on every call.
📐

Prompt Sanitizer - Token Savings

Formula Equation:
tokens saved = tokens before − tokens after (js-tiktoken cl100kbase); saving % = saved ÷ before × 100

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

  1. 1Sample prompt: 165 characters, 37 tokens
  2. 2Sanitized: 148 characters, 34 tokens
  3. 337 − 34 = 3 tokens saved (8.1%); 17 characters removed
📚

Sources & Further Reading

Frequently Asked Questions about Prompt Sanitizer

Frequently asked questions

Only whitespace: runs of blank lines collapse to one, trailing spaces are trimmed, tabs become two spaces, and common leading indentation is removed. Words, punctuation and line order are never touched.

With 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 an estimate.

Almost never — models ignore the whitespace that is removed. But test a sanitized prompt on a few real requests before deploying it to production, as with any prompt change.

No. Sanitizing and token counting run entirely in your browser. Nothing you paste leaves your device.

It depends on how messy the prompt is. The built-in sample saves 3 tokens (37 → 34, 8.1%) and 17 characters; a prompt that is already clean saves nothing, and the tool says so (“No waste found — the prompt is already clean”).

Yes — it only changes whitespace (blank lines, trailing spaces, tabs, indentation), so words in any language are left untouched.

Complementary utilities for your workflow

View all →
You are here

Prompt Sanitizer

Clean system prompts and see exact tokens saved.

Current tool

LLM Token Counter

Count tokens for GPT and Claude models, with cost estimates.

Try tool
Popular

Word Counter

Count words, characters, and reading time instantly.

Try tool

Text Compare

Diff two texts and highlight changes line-by-line.

Try tool