Loading ToolDeck, please wait.

ToolDeck.online

INITIALIZING_

0%
DESIGNED BY SJ VISUAL FLOW STUDIOS
ToolDeck.onlineOpen. Build. Go.

OpenAI Token Counter (GPT-4, GPT-3.5 & GPT-4o)

Exact token counts for GPT-4, GPT-3.5 and GPT-4o. No upload, no sign-up.

0 chars
Total tokensExact
—tokens

Loading tokenizer…

Characters
0
Words
0
Lines
0
Chars / token
—

Paste your text and instantly see how many tokens it uses. Switch between GPT-4 / GPT-3.5 (cl100k_base) and GPT-4o (o200k_base). Your prompt is never uploaded. No sign-up, no credits, no limits.

  • Exact API match
  • GPT-4 Turbo support
  • GPT-4o support
  • No upload
  • Runs offline

How many tokens is my OpenAI prompt?

Paste your prompt into the box above and pick your model. GPT-4 and GPT-3.5 use the cl100k_base tokenizer. GPT-4o uses o200k_base. Both are counted exactly as the API would count them. Use this to estimate costs or check if your prompt fits inside the context window.

Price
Free, no credits, no sign-up
Tokenizers
cl100k_base (exact) and o200k_base (exact)
Models covered
GPT-4, GPT-4 Turbo, GPT-3.5 Turbo, GPT-4o, GPT-4.1
Context Windows
8k (legacy), 16k (GPT-3.5), 128k (GPT-4/4o)
Text uploaded to server
No, runs 100% in your browser
Input
Any plain text, code, JSON or chat history
Extras
Characters, words, lines, chars-per-token ratio
Best browsers
Any modern browser (Chrome, Edge, Firefox, Safari)
Works offline
Yes, after the first load
Not included
Cost-per-1K calculator, batch file upload, saved history

What is the OpenAI token counter?

This is a free, browser-based tool that counts tokens for OpenAI models. It uses the official `cl100k_base` and `o200k_base` tokenizers, so the counts match the API exactly. Whether you are using older models like GPT-3.5 Turbo or the newer GPT-4o and GPT-4.1, you can check your prompt size with 100% accuracy. It also reports characters, words, lines and the chars-per-token ratio. No file is uploaded, no account is required and the tool works offline after the first load.

It is best for prompt engineering, API cost estimation, system prompt budgeting, and ensuring your long documents fit inside the context window. It is not built for counting image tokens (Vision) or calculating exact dollar amounts, because model prices change often.

How to count OpenAI tokens in 3 steps

  1. 1

    Paste your text

    Paste your prompt, system instruction, or conversation into the box. The tool counts as you type.

  2. 2

    Select the model

    Choose "GPT-4 / GPT-3.5" for cl100k_base, or "GPT-4o" for o200k_base. The tool uses the exact OpenAI tokenizers for both.

  3. 3

    Read the count

    Get the exact token count, plus character and word stats. Verify it fits your context window, then send it to the API.

Features

  • Exact API Matches

    We use the official cl100k_base and o200k_base tokenizers. The numbers you see here match the `usage.prompt_tokens` you get from the OpenAI API exactly. No estimates.

  • Legacy & Modern Models

    Whether you are maintaining an older app on GPT-3.5 Turbo or building a new agent on GPT-4o, this tool covers both tokenizers. GPT-4 Turbo is also fully supported.

  • Context Window Checks

    Check if your prompt fits inside the 8k, 16k, or 128k context windows. Avoid the frustrating "context length exceeded" errors by verifying the count before you send the request.

  • Instant Character & Word Stats

    Get a quick breakdown of characters, words, lines, and the chars-per-token ratio. This is useful for estimating prompt sizes and understanding how efficiently your text is being tokenized.

  • 100% Private

    The tokenizer runs locally in your browser using JavaScript. Your proprietary code, confidential data, and prompts are never sent to our servers or stored anywhere.

  • Zero Friction

    No accounts, no email capture, no credit card required. Just open the page, paste your text, and get your exact token count instantly.

What you can use the OpenAI counter for

  • GPT-3.5 cost optimization

    GPT-3.5 uses the cl100k_base tokenizer. If you are running high-volume, low-cost API calls, check the exact token count to ensure your pricing model stays profitable.

  • GPT-4 Turbo budgeting

    GPT-4 Turbo is cheaper than the original GPT-4 but still uses cl100k_base. Count your prompts before running a massive batch job to estimate your total API bill.

  • Migrating to GPT-4o

    Switching from GPT-4 to GPT-4o? Paste your current prompts and switch the dropdown to GPT-4o. The o200k_base tokenizer often uses fewer tokens for the same text, which can save you money.

  • Checking 16k limits

    Many legacy GPT-3.5 models have an 16k token limit. If you are processing long documents, check the count here to avoid API errors.

  • System prompt optimization

    System prompts are sent on every single turn of a conversation. Trimming a 500-token system prompt down to 200 tokens saves 300 tokens on every message.

  • Code review agents

    If you are building an AI coding assistant, code snippets are highly tokenized. Paste your code here to see how much of the context window it actually consumes.

OpenAI Token Counter FAQ

Answers about accuracy, context windows, pricing, and how cl100k_base differs from o200k_base.

Accuracy & Models

Does this cover all OpenAI models?

It covers the most common ones. GPT-3.5 Turbo, GPT-4, and GPT-4 Turbo use cl100k_base. GPT-4o and GPT-4.1 use o200k_base. If a new model uses one of these tokenizers, the count will be exact.

Does this match the OpenAI API exactly?

Yes. We use the official tokenizer libraries. The number you see here will match the `usage.prompt_tokens` returned by the API.

Why do GPT-3.5 and GPT-4 give different counts?

They use different tokenizers. GPT-4 and GPT-3.5 use cl100k_base. GPT-4o uses the newer o200k_base, which is more efficient, especially for non-English text.

Is my prompt saved or logged?

No. The tokenizer runs entirely in your browser. Your text is never sent to our servers, and it disappears when you close or refresh the page.

Context Windows & Cost

What are the context windows for these models?

GPT-3.5 Turbo typically has a 16k window. GPT-4 and GPT-4 Turbo have 128k windows. GPT-4o has a 128k window. The combined input and output must fit inside the window.

How do I calculate my API cost?

Find the current price per 1,000 tokens for your specific model (check OpenAI's pricing page). Multiply your token count by that price. ToolDeck does not display dollar amounts because prices change frequently.

What happens if I exceed the context window?

The API will reject your request. Use this tool to trim your prompt, remove older chat history, or summarize long documents before sending them.

Tokens vs Characters

How many characters is a token?

For plain English, 1 token is roughly 4 characters. Code, math, and non-English languages use more tokens per character. Look at the "Chars / token" stat for the exact ratio.

How many words is 1,000 tokens?

About 750 words of plain English. For code or non-English text, the word count will be lower.

What this tool does well, and where it is limited

This page covers OpenAI models, both legacy and modern. Check this table to see if it fits your use case.

OpenAI token counter use cases and results
Use caseResultNotes
Counting GPT-4 and GPT-3.5 tokensExactUses cl100k_base, matching the API exactly.
Counting GPT-4o and GPT-4.1 tokensExactUses o200k_base, matching the API exactly.
Counting Claude tokensUse Claude pageClaude uses a different tokenizer. Use the dedicated Claude Token Counter for approximations.
Counting image tokens (Vision)Not supportedImage tokens are calculated based on resolution and detail level, not plain text. This tool counts text only.
Calculating exact dollar costNot calculated herePrices change often and differ between input/output. Multiply the count by the current OpenAI pricing yourself.
Counting very large batch filesOne at a timePaste text into the box directly. For large datasets, write a script using the tiktoken library.

Tips

  • Switch tokenizers for cost savings

    If you are on the fence about which model to use, paste your prompt and switch between GPT-4 and GPT-4o. The o200k_base tokenizer used by GPT-4o is often more efficient, which can lower your per-request cost.

    Open the GPT-4o Counter

  • Watch out for whitespace

    Newlines and tabs count as tokens. If you are pasting formatted JSON or code, removing unnecessary whitespace can save tokens without losing meaning.

  • System prompts run every time

    A 1,000-token system prompt sent in a 10-turn conversation costs 10,000 tokens. Keep your system prompts as short as possible to optimize costs.

  • Code is token-heavy

    Code uses more tokens than English. If you are building a code analysis tool, always check the exact token count to ensure you do not blow past the context limit.

ToolDeck vs other token counters

Many generic token counters use older tokenizers and give you the wrong number for newer models. ToolDeck uses the exact match for both cl100k_base and o200k_base.

Comparison of ToolDeck OpenAI token counter and other tools
FeatureToolDeckGeneric counters
Uses exact OpenAI tokenizersYes, matches APIOften guesses or uses older versions
Supports GPT-4 and GPT-3.5 (cl100k)YesVaries by tool
Supports GPT-4o (o200k)YesVaries by tool
Your text is uploaded to a serverNeverUsually yes
Sign-up neededNot requiredOften
Free credits or paywallsNoneOften
Real-time counting as you typeYesUsually yes
Character, word and line countsYesSometimes
Works offline after loadingYesUsually no

General comparison. Individual tools differ, and features, limits and pricing change.

Responsible use

The counter is a reference tool. Always confirm the exact count with the provider's API before you depend on it in production. Prices and tokenizers change; this page is updated when they do.

More free AI and developer tools

Model-specific counters and other browser tools. Nothing uploaded, ever.

See all ToolDeck tools

Your prompts never leave your device

There is no upload step and no account. The tokenizer runs in your browser, so every count happens on your own device. You can check this yourself: open your browser developer tools, go to the Network tab, then paste text and watch for file uploads. You will not see any. Read how we keep it private.