Prompt Cleaner
Runs 100% in your browserRemove invisible characters, encoding artifacts, and copy/paste noise from prompt text — without rewriting a word. Local, deterministic, privacy-preserving.
Frequently asked questions
The Prompt Cleaner detects and removes copy/paste noise, invisible Unicode characters, encoding artifacts, and optionally selected presentation artifacts from prompt text. It can remove a Unicode BOM, strip zero-width characters, normalize CRLF line endings, remove trailing whitespace, trim outer blank space, collapse excessive blank lines, replace non-breaking spaces, remove suspicious C0/C1 control characters, normalize curly quotes, and normalize em/en dashes. Every change is shown in a cleanup report before you copy.
No. All cleaning runs entirely in your browser using JavaScript. Your prompt text is never uploaded to a server, sent to a language model, or transmitted to any external API. There are no network requests, no cloud processing, and no storage — not even in localStorage. Session history disappears when you close the tab.
A zero-width space (U+200B) is a Unicode character with no visible width that is commonly introduced when copying text from web pages, PDFs, or rich-text editors. When present in a prompt, it can split tokens unexpectedly, inflate the token count, and cause subtle differences in how a language model processes the surrounding text. The Prompt Cleaner detects all zero-width characters — including zero-width space (U+200B), zero-width non-joiner (U+200C), zero-width joiner (U+200D), word joiner (U+2060), and related invisible formatting characters — and reports them before removal.
A Unicode BOM (byte-order mark, U+FEFF) is a special character that appears at the start of a file to indicate the byte order and encoding. It is harmless in a file but can cause problems when pasted into a model context window, because some tokenizers treat it as part of the first token or produce an unexpected output token for it. The Prompt Cleaner detects a BOM at the start of the input and removes it when the "Remove BOM" option is enabled.
C0 control characters are Unicode code points in the range U+0000 to U+001F. Three are expected in normal text: tab (U+0009), line feed (U+000A), and carriage return (U+000D). The remaining 29 are rarely intentional in a prompt and can originate from binary data, null bytes, or corrupted clipboard content. C1 control characters (U+0080 to U+009F) are a Latin-1 supplement range used in legacy encodings. The Prompt Cleaner detects both categories and can remove them with the "Remove C0/C1 controls" option, while always preserving tab, LF, and CR.
The Prompt Formatter handles structural presentation: list marker normalization, ATX heading spacing, and blank-line collapsing. The Prompt Cleaner focuses on encoding hygiene: invisible characters, control characters, BOM detection, replacement-character detection, and line-ending normalization. Both tools preserve code fences and prompt variables, and neither rewrites or restructures your prompt. Use the Formatter when you want consistent presentation; use the Cleaner when you are concerned about invisible or transport artifacts.
The Prompt Optimizer performs heuristic structural analysis — detecting ambiguity, conflicts, missing output format, and section structure, and applying safe transformations like normalization and deduplication. The Prompt Cleaner is purely a noise-removal tool: it only removes characters that are invisible, control-class, or optionally selected cosmetic variants. It never rewrites sentences, reorders sections, or changes the meaning of your prompt.
When the "Preserve protected blocks" option is enabled (which is the default), the cleaner identifies and temporarily removes fenced code blocks (``` and ~~~), inline code spans, bare URLs, Markdown links [text](url), JSON-like blocks, and recognized prompt variables ({{name}}, ${topic}, [UPPERCASE], <variable>). These blocks are restored verbatim after cleaning — no whitespace or character normalization is applied inside them. The inspection report shows how many blocks were protected.
Prompt variables are template placeholders in formats like {{name}}, ${topic}, [OUTPUT_FORMAT], and <variable>. They are intentional parts of a prompt template that should not be altered. If the cleaner modified the spacing or encoding inside a variable, the template might break when it is filled in programmatically. The "Preserve protected blocks" option ensures all recognized variable formats are kept exactly as written.
The replacement character (�) is inserted by decoders when they encounter byte sequences that cannot be interpreted in the expected encoding. It marks the position of lost or corrupted data. The Prompt Cleaner detects replacement characters and reports their count but never removes them — because removing � would delete a marker that indicates something is wrong. The tool explains this clearly in the inspection report and leaves the decision to you.
A non-breaking space (U+00A0) prevents a line break between two words. It is commonly introduced when copying from web pages, Google Docs, or typeset PDFs. In a prompt, NBSP is usually unintentional and may tokenize differently from a regular space (U+0020). The "Replace NBSP with space" option converts all U+00A0 characters to regular spaces. This option is off by default because NBSP is occasionally intentional in multilingual or typographic contexts.
Yes, when the "Normalize line endings" option is enabled (which is the default). The cleaner converts CRLF (carriage return + line feed, \r\n) and bare CR (\r) to LF (\n). This is the safest normalization because LF is the standard line ending for Unix, web, and most modern text processing environments, and because CRLF can occasionally cause tokenization differences when a prompt is pasted from a Windows text editor.
Yes. The cleaner is pure JavaScript with no size limit imposed by a server. Very large inputs (tens of thousands of characters) will process in milliseconds. The file-open button accepts .txt, .md, .markdown, and .prompt files read by the browser FileReader API — no file data is uploaded anywhere.
The inspection report shows a summary chip row with character count, line count, and detected anomaly counts. If invisible characters are found, a table lists each code point, its Unicode name, its category, and how many times it appears. If C0/C1 control characters are detected, a second table lists each one. If replacement characters are present, a warning explains the limitation. If protected blocks were detected, a note shows how many will be preserved.
After you click Clean Prompt, the cleanup report lists every transformation that ran, with the count of instances changed. Each item is color-coded: green for successful cleanups, amber for warnings (such as replacement character detection), and blue for informational items (such as protected blocks preserved). If no changes were needed, the report says so explicitly.
The Swap button copies the cleaned output back into the input field, clearing the output. This is useful when you want to run a second cleaning pass on the result — for example, applying the BOM removal in a first pass and then the NBSP normalization in a second pass with different options selected.
Yes. The cleaner works on any text — system prompts, user turn messages, few-shot examples, or any other prompt component. Encoding artifacts can appear in any pasted text regardless of where it will be used in a conversation.
When the "Normalize curly quotes" option is enabled, the cleaner replaces left and right single quotation marks (‘ U+2018 and ’ U+2019) with the straight apostrophe (') and left and right double quotation marks (“ U+201C and ” U+201D) with the straight double quote ("). This option is off by default because Unicode quotation marks are valid and often intentional. Enable it only if you need pure ASCII punctuation.
When the "Normalize dashes" option is enabled, the em dash (— U+2014) is replaced with two hyphens (--) and the en dash (– U+2013) is replaced with a single hyphen (-). This option is off by default because em and en dashes are semantically distinct from hyphens and are valid Unicode characters. Enable it only if the downstream tool or model context requires pure ASCII punctuation.
No. The Prompt Cleaner removes noise and encoding artifacts — it does not claim that cleaning improves model reasoning, compliance, factuality, or output quality. A clean prompt is easier to audit and has more predictable tokenization, but the tool cannot predict how a specific model will respond to it.
Yes. The Prompt Cleaner is completely free with no registration, no API key, no subscription, and no rate limits. All processing is done in your browser using vanilla JavaScript.
Yes. Once the page has loaded, all cleaning, inspection, copy, and download operations run entirely in your browser with no network calls. You can use it without internet access after the initial page load.
The session history records the last eight cleaning operations in the current browser tab. Each entry shows a preview of the input text, the time, and the number of changes applied. You can click Reuse on any history entry to reload that input into the editor. Session history is memory-only — it disappears when you close or reload the tab and is never written to localStorage or any persistent storage.
What is Prompt Cleaner?
What Is a Prompt Cleaner?
A prompt cleaner is a tool that removes copy/paste noise, hidden Unicode characters, encoding artifacts, and transport-layer junk from prompt text before you send it to a language model. It is distinct from a prompt formatter (which normalizes presentation like heading spacing and list markers) and from a prompt optimizer (which analyses structure and suggests clarity improvements). A cleaner has a narrower and more fundamental job: remove characters that should not be there without touching a single word of the actual content.
The need for a dedicated cleaner arises because of how prompts are assembled in practice. You copy a paragraph from a Google Doc and it arrives with non-breaking spaces (U+00A0) and zero-width joiners (U+200D) that were inserted by the document editor. You paste a system prompt from a Windows Notepad file and every line ends with CRLF (\r\n) instead of LF (\n). You move text through a PDF and the reader inserts invisible soft hyphens (U+00AD) at word-break positions. You receive a prompt template through email or a web form and the BOM character (U+FEFF) lands at the start. None of these artifacts are visible in a text editor, but all of them are present in the byte stream that the tokenizer receives.
Tokenizers are sensitive to byte-level encoding. The non-breaking space U+00A0 does not tokenize the same way as the regular space U+0020 — some tokenizers treat it as a word character, which can cause "word" and "word" (with NBSP) to become different tokens. A zero-width joiner U+200D between two letters can fuse them into a single token that the model has rarely or never seen in training. A BOM at the start of a prompt may be encoded as a separate token that effectively consumes part of the context window. The Prompt Cleaner makes these invisible characters visible by name, shows their code point and count in an inspection table, and removes only the ones you explicitly choose to remove.
What the Cleaner Detects and What It Preserves
The inspection engine scans for thirty-two specific invisible and suspicious Unicode character categories: the byte-order mark (U+FEFF), the zero-width space family (U+200B, U+200C, U+200D, U+2060, U+2061), the typographic space family (U+2000–U+200A, U+202F, U+205F, U+3000), non-breaking space variants (U+00A0, U+202F), the soft hyphen (U+00AD), and several C1-range control characters. It also detects C0 control characters outside the three expected ones (tab, LF, CR), CRLF and bare CR line endings, trailing whitespace on individual lines, outer blank space, excessive blank-line runs, and double-space runs.
Critically, the cleaner identifies and protects content that should not be touched: fenced code blocks delimited by `` or ``~, inline code spans, bare URLs, Markdown links in [text](url) format, JSON-like structures, and recognized prompt template variables in formats such as {{name}}, ${topic}, [OUTPUT_FORMAT], and <variable>. These blocks are replaced with placeholders before any transformation runs and restored verbatim afterward — so cleaning a prompt that contains a Python code example will leave the code exactly as written, even if it contains intentional blank lines, specific indentation, or raw control sequences.
What the Cleaner Does Not Do — and Why That Matters
The Prompt Cleaner does not reorder prompt sections, rewrite sentences, remove substantive content, apply Markdown formatting rules, or perform semantic prompt optimization. These are the responsibilities of Prompt Formatter, Prompt Optimizer, and Prompt Markdown Formatter respectively.
The cleaner also does not claim comprehensive PII detection. Removing invisible characters does not sanitize a prompt of personally identifiable information — that is a different problem that requires content-aware processing. It does not claim to make a prompt safe, secure, or free of sensitive data merely because the encoding artifacts have been removed.
The replacement character (U+FFFD) is a special case. This character is inserted by decoders when they encounter byte sequences that cannot be interpreted in the expected encoding. It marks the position of lost data. The cleaner detects replacement characters and reports their count, but it never removes them — because removing U+FFFD would delete a marker that indicates something is wrong with the source text. The presence of replacement characters suggests that the original encoding was not UTF-8 or that the text was processed by a tool that silently corrupted non-ASCII bytes.
Finally, the cleaner never claims that removing noise improves model reasoning, compliance, factuality, or output quality. It claims exactly what it can demonstrate: that after cleaning, the text contains fewer invisible characters, has normalized line endings, and has the specific artifacts you chose to remove.
Common use cases
- Cleaning a prompt copied from Google Docs that contains NBSP and zero-width joiners introduced by the editor
- Normalizing CRLF line endings in a system prompt pasted from a Windows text file into a Unix API client
- Detecting a BOM character at the start of a prompt file opened from a UTF-8-with-BOM Windows editor
- Inspecting a prompt template received by email to identify invisible characters before using it in production
- Removing trailing whitespace from a multi-line prompt to ensure consistent tokenization across model providers
- Cleaning a prompt that was passed through a PDF reader and may contain soft hyphens at word-break positions
- Identifying replacement characters (U+FFFD) in a prompt to find corrupted sections before sending to an API
- Normalizing curly quotes and em dashes in a prompt that must use pure ASCII punctuation for a legacy tool
Why use ToolsSonic's Prompt Cleaner?
ToolsSonic Prompt Cleaner is the only browser-based tool that separates encoding hygiene from prompt formatting and optimization into a dedicated, explainable, and privacy-preserving workflow. It does not claim to improve model performance — it claims to make invisible encoding artifacts visible and removable.
The inspection table names every detected invisible character by its Unicode code point, standard Unicode name, category, and count. You see exactly what is present before you decide to remove it. No other free browser-based prompt tool provides this level of encoding transparency.
Protected content behavior is conservative by design. Fenced code blocks, inline code, URLs, Markdown links, and prompt variables are identified and preserved verbatim — the tool never applies whitespace or character normalization inside protected blocks, and it tells you how many blocks were protected. If protection cannot be detected confidently for a region, the tool does not apply the transformation and notes the region as potentially ambiguous.
The privacy architecture is strict: no network calls during operation, no localStorage writes, no analytics injection into user content, no prompt text in page metadata or error messages. Session history is memory-only. The tool makes one accurate claim about privacy and repeats it in the footer: "Cleaning runs locally in this browser. Your prompt is not uploaded or sent to a model."
Invisible Character Reference — What the Cleaner Detects
| Code point | Name | Category | Common source |
|---|---|---|---|
| U+FEFF | Byte-order mark (BOM) | bom | UTF-8-with-BOM editors (Windows Notepad legacy), file exports |
| U+200B | Zero-width space (ZWSP) | zwsp | Web pages, CMS editors, copy from browsers |
| U+200C | Zero-width non-joiner (ZWNJ) | zw | Arabic/Persian/Indic script word processing |
| U+200D | Zero-width joiner (ZWJ) | zw | Emoji sequences, script ligature control, web copy |
| U+2060 | Word joiner | zw | Word processors preventing line breaks |
| U+00A0 | Non-breaking space (NBSP) | nbsp | Google Docs, HTML copy/paste, typesetting tools |
| U+202F | Narrow no-break space | nbsp | French typography, number formatting |
| U+00AD | Soft hyphen | soft | PDF readers, hyphenation engines |
| U+2000–U+200A | Typographic spaces (11 variants) | typospace | Desktop publishing, web typography, LaTeX conversion |
| U+2028 | Line separator | ctrl | JavaScript string escapes, some serializers |
| U+2029 | Paragraph separator | ctrl | JavaScript string escapes, some serializers |
| U+FFFD | Replacement character | (detected, never removed) | Encoding conversion errors, binary data, corrupted clipboard |
| U+0000–U+001F (excl. 09/0A/0D) | C0 control characters | ctrl | Null bytes, binary file copy, corrupted data |
| U+0080–U+009F | C1 control characters | ctrl | Legacy Latin-1 encodings, Windows-1252 artifacts |
Prompt Cleaner vs Prompt Formatter vs Prompt Optimizer
| Capability | Prompt Cleaner | Prompt Formatter | Prompt Optimizer |
|---|---|---|---|
| Remove invisible Unicode characters | ✅ primary function | ✅ included | ✅ included |
| Named code-point inspector with counts | ✅ | — | — |
| Detect replacement character (U+FFFD) | ✅ warns, preserves | — | — |
| Detect C0/C1 control characters | ✅ | — | — |
| Normalize CRLF → LF | ✅ | ✅ | ✅ |
| Remove trailing whitespace | ✅ | ✅ | ✅ |
| Collapse blank-line runs | ✅ opt-in | ✅ | ✅ |
| Normalize ATX heading spacing | — | ✅ | ✅ |
| Normalize list markers | — | ✅ | ✅ |
| Normalize curly quotes / dashes | ✅ opt-in | — | — |
| Heuristic ambiguity / conflict suggestions | — | — | ✅ |
| Section detection | — | — | ✅ |
| Placeholder detection | preserved only | preserved only | ✅ detected + listed |
| Rewrite or restructure prompt text | ❌ never | ❌ never | ❌ never |
| Network calls or uploads | ❌ zero | ❌ zero | ❌ zero |
Related tools
Prompt Formatter
Editor's choiceClean and normalize AI prompts: strip invisible characters, trim whitespace, collapse blank lines, normalize list markers and headings — all in your browser.
Prompt Optimizer
Editor's choiceClarify, organize, and review AI prompts locally — normalize whitespace, detect sections, flag ambiguity and repetition, and see every change before you copy.
Trim Whitespace
Editor's choiceTrim leading and trailing spaces, normalize internal whitespace, clean tabs, handle Unicode whitespace, and control blank lines — privately in your browser.
Text Formatter
Editor's choiceFormat and clean text online with transparent presets for copied prose, plain text, developer content, lists, and data. Normalize whitespace, line breaks, typography, Unicode, markup, case, duplicates, and sort order locally in your browser. No upload, no grammar rewrite, no persistent storage.
Character Counter
Editor's choiceCount characters with and without whitespace, Unicode graphemes, code points, words, bytes, SMS estimates, and platform-limit fit in your browser.
Find and Replace
Editor's choiceFind and replace text locally with literal or regular-expression rules, ordered multi-rule editing, capture groups, match counts, audits, quick presets, and private file support.