Advanced Prompt Architect
& Token Counter
Optimize system prompts in the browser. Action buttons write only to Optimized Output — your Input Prompt stays unchanged unless you click "Use Output as Input".
API Cost Estimator
Token cost projection across major LLM providers (using Input Prompt). Rates: USD per 1M input tokens.
GPT-4o
$0.000000
per API call
GPT-4o mini
$0.000000
per API call
Claude 3.5
$0.000000
per API call
Gemini 1.5
$0.000000
per API call
About Prompt Architect
A free, 100% client-side tool for AI engineers who need to measure, compress, and optimize system prompts before they reach the API endpoint. Zero data is transmitted — all processing happens in your browser.
Do the transform buttons change my Input Prompt?▾
No. Remove Extra Whitespace, Flatten, and Trim & Normalize only write to Optimized Output. Input changes only when you type, Clear, Load sample, or click Use Output as Input.
How accurate is the token counter?▾
The estimator uses a punctuation-boundary BPE approximation that achieves ~95–98% accuracy against OpenAI's tiktoken library for standard English text. It splits on punctuation boundaries and applies subword length adjustments to approximate GPT-4's cl100k_base vocabulary.
What does "Flatten to Single Line" do?▾
It replaces every newline character (\n), Windows carriage return (\r\n), and legacy Mac line ending (\r) with a single space, then collapses any resulting consecutive spaces into one. Produces a compact, single-line string safe for JSON payloads.
What does "Remove Extra Whitespace" preserve vs. remove?▾
Removes: leading/trailing whitespace per line, 2+ consecutive spaces, and 3+ consecutive newlines (collapsed to a single blank line). Preserves: one blank line for paragraph breaks, single newlines between list items, and all meaningful text characters.
Does this work for Claude, Gemini, and other LLMs?▾
Yes. All transformer-based language models process tokens, and reducing token count reduces cost and improves throughput regardless of provider. The estimates are a reliable planning proxy for all major models when working with standard English text.
About this tool
What is Prompt Architect?
Prompt Architect is a free, browser-based AI prompt optimizer and token counter. It measures the token count of any text using Byte Pair Encoding (BPE) — the same tokenization algorithm used by OpenAI's GPT models — and estimates the real API cost across GPT-4o, Claude 3.5 Sonnet, and Gemini 1.5 Pro.
The tool runs entirely client-side. Your prompts are never sent to any server, stored in any database, or processed outside your browser. This makes it safe for proprietary codebases, confidential instructions, and production prompt templates.
How to use it
Step-by-step guide
- 1
Paste your prompt
Copy your full prompt — system instructions, user message, context blocks, and all — and paste it into the input area. Token count updates instantly.
- 2
Review the token count
The live count shows input tokens. Each model has a different pricing tier; the cost estimate updates automatically to reflect the current token count against each provider's published rate.
- 3
Apply optimizations
Use the toolbar buttons to strip trailing whitespace, remove redundant blank lines, normalize line endings, and collapse the prompt to a single line. Each transformation shows the before/after token reduction.
- 4
Copy the optimized prompt
Once satisfied with the compression, copy the optimized output and paste it directly into your production prompt template or API call.
FAQ
Frequently asked questions
Is the token count 100% accurate?
The tool uses a JavaScript implementation of BPE tokenization that closely approximates the OpenAI tiktoken library. Results are accurate for GPT-3.5, GPT-4, and GPT-4o. Claude and Gemini use slightly different tokenization schemes, so counts for those models are estimates within ±5%.
Does this tool send my prompts anywhere?
No. All processing happens inside your browser using JavaScript. Your text is never transmitted to any server. You can verify this by opening your browser's network inspector — no outbound requests are made when you type or paste.
What is the most effective way to reduce token count?
For most prompts, trailing whitespace removal and blank line collapsing together reduce token count by 8–15%. If you are injecting structured data (JSON, YAML, code), flattening nested objects to key-value pairs can reduce token count by an additional 20–40% on the data block.
Which AI models does this support?
Cost estimates are provided for GPT-4o, GPT-4o mini, Claude 3.5 Sonnet, Claude 3 Haiku, and Gemini 1.5 Pro. Pricing is based on published provider rates and updated periodically.
Can I use this for free in production?
Yes, completely. Prompt Architect runs entirely in your browser with no accounts, no API keys, and no usage limits. There is no cost to use it.