Prompt Formatter

Runs 100% in your browser

Clean and normalize AI prompts: strip invisible characters, trim whitespace, collapse blank lines, normalize list markers and headings — all in your browser.

PROMPT FORMATTING WORKSPACE

Prompt Formatter

Clean whitespace, strip invisible characters, normalize lists and headings — every change visible before you copy.

Local only

Frequently asked questions

The Prompt Formatter cleans and normalizes the text of an AI prompt. It can strip invisible characters such as non-breaking spaces, zero-width joiners, and BOM markers; remove trailing whitespace from each line; collapse multiple consecutive blank lines; normalize mixed list markers (*, •, 1) to a consistent style; and normalize ATX heading spacing. Every change is deterministic and previewed before you copy.

No. All formatting runs entirely in your browser using JavaScript. Your prompt text is never sent to a server, model, or external API. There is no network request, no upload, and no storage — not even in localStorage. Session history disappears when you close the tab.

Invisible characters are Unicode code points that render as blank space or nothing at all. Common examples include the non-breaking space (U+00A0), zero-width space (U+200B), zero-width non-joiner (U+200C), zero-width joiner (U+200D), byte-order mark (U+FEFF), and various typographic spaces (U+2000–U+200A). When pasted into a model context window, these can confuse tokenizers, split tokens unexpectedly, or inflate token counts — causing subtle misbehaviours in model output.

The Prompt Formatter focuses purely on whitespace and structural formatting — it never changes the words or meaning of your prompt. The Prompt Optimizer additionally performs heuristic analysis (detecting ambiguous instructions, conflicting directives, missing output format, section structure) and offers deterministic rewrites such as deduplication and section reordering. Use the Formatter when you want clean text without any semantic changes; use the Optimizer when you want a deeper structural review.

The normalizer converts bullet markers including asterisk (*), bullet (•), em-dash (—), en-dash (–), chevron (›), triangle (▶), and diamond (◆) into a standard hyphen-space (- ). Numbered list items such as "1)" or "a." are converted to "1." format. Multi-character markers like "--" are also caught. Code fences (``` blocks) are protected and never altered.

ATX headings are lines that start with one or more # characters. The normalizer ensures there is exactly one space between the # symbols and the heading text, and removes any trailing # characters on the same line (e.g. "## Title ##" becomes "## Title"). This is the standard Markdown heading style recommended by the CommonMark spec and by most LLM system-prompt guides.

Collapse Blank Lines reduces runs of consecutive blank lines to a maximum number you choose (1, 2, or 3). For example, if you have five blank lines between two paragraphs and set the maximum to 2, the output will have exactly 2 blank lines there. Leading and trailing blank lines in the document are also removed.

Before formatting, the tool temporarily replaces all ``` fenced code blocks with placeholders. After formatting is complete, the original code blocks are restored verbatim. This means that whitespace, list markers, and headings inside code blocks are never touched — preserving code examples exactly as written.

Yes. The formatter is pure JavaScript with no size restrictions imposed by a server. However, very large inputs (tens of thousands of characters) may take a fraction of a second to process. The file-open button accepts .txt, .md, .markdown, and .prompt files up to 500 KB.

The Statistics tab shows five metrics: input characters, output characters, changes applied (count of the six transformation types that fired), invisible characters stripped, and whitespace changes made. These help you audit exactly how much the formatter changed.

The Diagnostics tab shows per-rule findings: green items confirm that a transformation ran cleanly, blue items are informational (e.g. code fences protected), and amber items flag conditions worth reviewing — such as a very high invisible-character count suggesting the text may have been pasted from a PDF or a rich-text editor with heavy encoding artifacts.

The History tab shows the last eight formatting operations in the current browser session. Each entry records a preview of the input, the timestamp, and the count of changes applied. Session history is memory-only and disappears when you close or reload the tab — nothing is persisted.

Yes. Press Ctrl+Enter (or Cmd+Enter on Mac) while the input textarea is focused to run the formatter. This matches the keyboard shortcut used across all ToolsSonic text tools for consistency.

When you enable Live Update, the formatter re-runs automatically 380 ms after you stop typing. This is useful for real-time cleanup as you draft a prompt. The live run does not add a history entry — only manual runs via the Format Prompt button or Ctrl+Enter do.

The Swap to Input button copies the formatted output back into the input field, clearing the output. This is useful when you want to make further manual edits to the formatted result and then re-run the formatter on it.

Copy Report copies a plain-text audit report to your clipboard. The report includes the original and formatted text, all applied options, the statistics, and per-transformation counts. It is useful for documenting exactly what was changed before sharing the prompt with a colleague.

Yes. The formatter works on any text — system prompts, user turn messages, few-shot examples, or any other prompt component. The formatting rules are the same regardless of where in the conversation the text will be placed.

Trailing whitespace is most commonly introduced by copy-pasting from web pages, PDF readers, or office documents, where lines may include trailing spaces or non-breaking spaces. It can also appear when editing prompts in plain-text editors that do not auto-trim. While most models ignore trailing whitespace, some tokenizers encode it distinctly, and it can inflate token counts slightly.

No. All transformations are purely presentational. Stripping invisible characters removes code points that are invisible to readers. Trimming trailing whitespace removes non-visible content at line ends. Collapsing blank lines reduces vertical whitespace. Normalizing list markers replaces equivalent visual bullets. Normalizing heading spacing ensures one space after #. None of these operations alter the readable text content of your prompt.

The Open File button accepts .txt, .md, .markdown, and .prompt files. The file is read locally by the FileReader API — it is not uploaded anywhere. The size limit is 500 KB.

A plain text editor shows you the text but does not analyse or apply formatting rules. The Prompt Formatter is specific to the concerns of AI prompt preparation: it understands invisible-character categories, code-fence protection, ATX heading syntax, and list-marker normalization. It also provides a statistics panel, a diagnostics report, and session history — none of which are available in a text editor.

Yes. The Prompt Formatter 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.

Switch to the "Diff view" tab in the analysis panel after formatting. It shows a line-by-line diff with red lines for removed content and green lines for added content. Word-level differences are highlighted inside each changed line so you can see the precise character-level edits — for example, a trailing space being removed or a bullet character being normalised. This lets you audit every change before you copy the output.

Yes. After formatting, open the "Placeholders" tab in the analysis panel. The formatter scans the output for common placeholder patterns — double-brace ({{var}}), single-brace ({var}), angle-bracket (<VAR>), and ALL_CAPS tokens — and lists each unique match as a chip with a count badge. This is useful when you want to verify that all template variables survived the formatting pass intact.

The Sections tab shows a structural outline of your formatted prompt derived from ATX headings (lines starting with ##). Each entry shows the line number and the heading text. This gives you a quick map of a long system prompt or few-shot template so you can verify the section order without scrolling through the full text.

The token gauge below the output estimates the approximate token count of your formatted prompt using the cl100k_base heuristic (roughly 4 characters per token) and compares it against the selected model's context window. Choose the target model from the dropdown — options include GPT-4o (128K), Claude 3.5 Sonnet (200K), Gemini 1.5 Pro (1M), Llama 3 70B (8K), and five others. The gauge bar is green below 60%, amber at 60–85%, and red above 85%. This helps you confirm your prompt fits within the model's context limit before you send it.

When enabled, the "Remove duplicate lines" option removes any line in the prompt that is an exact duplicate of a previous line (after optional trimming). This catches accidental copy-paste repetitions in long few-shot examples or system prompts. Like all other options, it is off by default and does not alter code fence content.

What is Prompt Formatter?

What Is a Prompt Formatter?

A prompt formatter is a tool that applies deterministic, rule-based cleaning to the text of an AI prompt before you send it to a language model. Unlike a prompt optimizer — which analyses structure, detects potential ambiguity, and may suggest rewrites — a formatter restricts itself to purely presentational changes: removing invisible characters, trimming trailing whitespace, collapsing blank-line runs, and normalizing list markers and heading syntax. Nothing about the meaning of your prompt changes; only the way it is encoded changes.

This distinction matters more than it might seem. Modern language models receive prompts as token sequences, and tokenizers are sensitive to the exact byte-level encoding of the text. A non-breaking space (U+00A0) does not tokenize the same way as a regular space (U+0020). A zero-width joiner (U+200D) can fuse two words into a single token. A BOM character (U+FEFF) at the start of a prompt may be interpreted as part of the first token. Invisible characters introduced by copying from a PDF, a rich-text editor, or a web page can silently inflate your token count, alter how the model splits words, and produce subtly unexpected outputs — all without any visible sign in most text editors.

Trailing whitespace and excess blank lines are less exotic but still worth cleaning. Some tokenizers give different IDs to "word" and "word " (with a trailing space). Blocks of four or five blank lines between prompt sections add tokens without adding meaning. A tidy prompt is also easier to read, audit, and compare against previous versions — which is why source code formatters have been standard tools in software development for decades.

What the Six Formatting Options Do

The Prompt Formatter offers six opt-in transformations, each independently toggleable.

Strip invisible characters removes twelve categories of Unicode code points that are invisible to human readers but present in the byte stream: non-breaking space (U+00A0), zero-width space (U+200B), zero-width non-joiner (U+200C), zero-width joiner (U+200D), word joiner (U+2060), function application (U+2061), byte-order mark (U+FEFF), and the full range of typographic spaces (U+2000 through U+200A — em space, en space, thin space, hair space, and six variants in between). Each stripped character is counted and reported in the Diagnostics tab so you can see exactly where your text had encoding artifacts.

Remove trailing whitespace strips spaces and tabs from the end of each line. Trailing whitespace is one of the most common side-effects of copy-pasting from web pages and PDF readers. It is invisible in most interfaces but present in the text stream.

Collapse multiple spaces reduces runs of two or more consecutive spaces to a single space. Leading indentation is preserved — the collapsing only applies to internal runs within a line, not to the leading spaces that represent intentional indentation levels.

Collapse blank-line runs reduces sequences of consecutive blank lines to a maximum count you choose: 1, 2, or 3. This is the most visible structural transformation — prompts pasted from documents often arrive with four or five blank lines between sections that are better represented as one or two. The maximum count is configurable so you can match the specific convention you prefer.

Normalize list markers converts the many different bullet characters that appear in pasted text — asterisk (*), bullet (), em-dash (), en-dash (), chevron (), triangle (), diamond () — to a standard hyphen-space (- ). Numbered lists in various formats (1), a., A.) are normalized to the standard 1. dot format. Code fences are protected and never altered.

Normalize ATX headings ensures that every ATX heading line (lines starting with #) has exactly one space between the # characters and the heading text, and that any trailing # characters are removed. This follows the CommonMark specification and the heading-formatting conventions recommended in most LLM system-prompt style guides.

Code-Fence Protection, Session Privacy, and Format Report

Before any transformation runs, the formatter scans the input for ```-delimited fenced code blocks and replaces them with numbered placeholders. After formatting is complete, the original code blocks are restored verbatim. This means that code examples, JSON snippets, shell commands, and XML blocks embedded in a prompt are never touched by list normalization or heading normalization — only the prose sections of the prompt are processed.

Session privacy is absolute. The formatting engine runs entirely in the browser using vanilla JavaScript. There is no server request, no API call, no cloud service, and no storage — not even in localStorage. The History tab shows the last eight runs in memory; it is wiped when the tab is closed. The Copy Report button produces a plain-text audit document that records the original text, the formatted output, every applied option, and per-transformation counts — useful for sharing with colleagues or for documenting prompt changes in a review process.

Common use cases

  • Cleaning copy-pasted prompts from PDF readers that introduce NBSP and typographic spaces
  • Normalizing list bullet styles when combining prompt sections written at different times
  • Removing excess blank lines from long system prompts before measuring token count
  • Standardizing ATX heading syntax in structured few-shot prompt templates
  • Stripping BOM and zero-width characters from prompts sourced from external documents
  • Preparing a prompt for version comparison by removing formatting noise
  • Auditing exactly which invisible characters are present in a suspicious prompt
  • Re-formatting a prompt after editing in a rich-text tool that introduces spurious markup

Why use ToolsSonic's Prompt Formatter?

ToolsSonic Prompt Formatter runs 100% in your browser — your prompt never touches a server or model. It is the only browser-based prompt formatter that shows a per-character invisible-character audit, protects code fences, offers six independently toggleable rules, and produces a downloadable plain-text report. Unlike text editors, it is specifically designed for AI prompt preparation: it understands the tokenizer-relevant differences between visible whitespace and invisible Unicode, and between regular spaces and non-breaking spaces. Free, no registration, no upload, no rate limit.

Invisible Character Reference

All twelve invisible character categories detected and removed by the Strip Invisible Characters option.

Code PointNameCommon SourceTokenizer Risk
U+00A0Non-breaking space (NBSP)HTML copy-paste, Word, PagesTokenizes differently from U+0020
U+200BZero-width spaceWeb editors, Medium, NotionMay split tokens invisibly
U+200CZero-width non-joinerRTL text, CMS exportsDisrupts ligature tokenization
U+200DZero-width joinerEmoji sequences, RTL textFuses adjacent tokens
U+2060Word joinerOffice documentsPrevents line-break at token boundary
U+FEFFByte-order mark (BOM)Windows Notepad, UTF-8 BOM filesPrepended to first token of prompt
U+2000–U+200ATypographic spaces (7 types)InDesign, LaTeX, typeset PDFsEach tokenizes as a distinct ID
U+2061Function applicationMathML, equation editorsInvisible semantic marker

ToolsSonic vs Top Prompt Formatting Tools

Feature comparison against the five most commonly used tools for cleaning AI prompt text.

FeatureToolsSonicTrim WhitespaceText FixerCode BeautifyPromptPerfectFlowGPT
Invisible char audit (12 types)partialpartial
Code-fence protection
List marker normalization
ATX heading normalization
Blank-line collapse (configurable max)partialpartialpartial
Downloadable format report
Zero upload / no serverpartialpartial
100% private — runs in your browser Instant — no server round-trip Free forever — no account needed