ChatGPT Context Counter is a Chrome/Chromium extension that estimates how much of the current ChatGPT conversation context is in use. It adds a small overlay on chatgpt.com with a percentage, token estimate, and a basic breakdown.
This project is currently preparing for a public beta release. The extension is useful today, but it is still best described as an estimate rather than an exact measurement.
- Estimates token usage from the conversation text loaded in the page.
- Shows total estimated tokens, chat text tokens, overhead tokens, and percent used.
- Optional per-message token usage badges (tokens and context-window percent) in chat history.
- Supports two estimation methods:
Fast: character-based heuristicPrecise: bundled tokenizer-based estimate
- Lets you manually select your ChatGPT plan and model.
- Auto-refreshes estimates when ChatGPT page/tab navigation changes within the app.
- Warns when the visible history may be incomplete.
- Stores your selected settings locally in the browser.
- Attachments are not implemented yet and are not included in totals.
- Automatic model detection is not implemented yet; model selection is manual.
- Only regular chat pages are supported (
/new chat and/c/<conversation-id>). - ChatGPT Projects and other non-regular layouts are not supported and show
Unsupportedin the overlay. - Estimates only use content currently present in the DOM, so unloaded or virtualized history can make totals low.
- Very large chats can cause
Preciseestimation to fall back toFast. - The extension is informational only and should not be treated as an exact tokenizer for ChatGPT web internals.
- Chrome
- Chromium
- Edge
- Brave
Any Chromium-based browser that supports Manifest V3 extensions should work, but Chrome/Chromium-based desktop browsers are the intended target.
- Open
chrome://extensions. - Enable
Developer mode. - Click
Load unpacked. - Select this repository folder.
- Open
https://chatgpt.comand start or open a conversation.
- Open ChatGPT on
https://chatgpt.com. - Find the collapsed counter in the bottom-right corner.
- Click it to expand the panel.
- Select your plan and model manually.
- Choose
FastorPreciseestimation. - Estimates auto-refresh as you navigate between supported chat pages.
- Use
Recalculateas an optional manual refresh after loading more history. - Enable
Per-message usagein the panel to show small token/percent badges next to each message.
Chat textis based on visible conversation text only.Overheadis a fixed reserve for system and formatting costs.Attachmentscurrently showNot implemented.Context sizeuses built-in defaults for the selected plan/model unless you change the code defaults in the project.
For the in-extension explainer, see learn.html.
- The extension reads conversation content from the open
chatgpt.compage in order to estimate tokens. - Processing happens locally in your browser.
- Settings are stored locally with
chrome.storage.local. - The extension does not send analytics, telemetry, or conversation contents to an external server.
See PRIVACY.md for the full privacy policy.
- Report bugs or request features via GitHub issues:
https://github.com/namerror/countcontext/issues
CHANGELOG.mdtracks public-facing release history starting with0.9.0.
Agent session logs live in docs/devlogs/. See docs/devlogs/README.md for the format and docs/devlogs/Index.md for the index.
manifest.json,config.js,background.js: extension entrypoints and shared runtime configuration.content.js,content/namespace.js,content/core/*,content/ui/*: the in-page runtime loaded onchatgpt.com.estimators/*,tokenizers/ccx-tokenizer.js,vendor/gpt-tokenizer/*: token estimation and bundled tokenizer support.styles.css,learn.html,learn.css,scripts/*,docs/*: UI styling, explainer page, tooling, and project docs.
Main program flow:
manifest.jsoninjects the content-script stack onhttps://chatgpt.com/*and registersbackground.jsas the MV3 service worker.config.jspublishes defaults and model metadata onwindow.__ccxConfig.content/namespace.jscreateswindow.__ccxContentso later files can register focused core and UI helpers.estimators/registry.js,estimators/*.js,tokenizers/ccx-tokenizer.js, andvendor/gpt-tokenizer/*attach shared estimation services onwindow, includingwindow.__ccxEstimatorRegistryandwindow.__ccxTokenizer.content/core/*andcontent/ui/*attach page parsing, estimation, observer, rendering, and drag helpers intowindow.__ccxContent.content.jsacts as the composition root: it loads stored settings, creates the overlay, reads page state, calculates estimates, wires observers, and re-renders when the DOM or URL changes.background.jsonly handles the learn-page request and openslearn.html.
Main source JS relationships:
content.jsdepends onwindow.__ccxConfig,window.__ccxContent,window.__ccxEstimatorRegistry,window.__ccxTokenizer, and the focusedcontent/core/*andcontent/ui/*modules.content/core/page-context.jsreads the ChatGPT DOM and returns message/support-state data.content/core/estimate-engine.jsturns page context plus settings into token totals, context sizes, and dropdown options.content/core/runtime-observers.jsprovides the debounce, DOM observation, and SPA navigation hooks that trigger refreshes.content/ui/overlay-view.jsowns overlay DOM creation, rendering, and UI event wiring.content/ui/overlay-drag.jsowns draggable positioning and persistence callbacks for the overlay shell.estimators/fast.jsandestimators/precise.jsregister the shipped estimators.
flowchart TD
manifest["manifest.json"]
config["config.js\nwindow.__ccxConfig"]
namespace["content/namespace.js\nwindow.__ccxContent"]
registry["estimators/registry.js\nwindow.__ccxEstimatorRegistry"]
estimators["estimators/fast.js\nestimators/precise.js"]
tokenizer["tokenizers/ccx-tokenizer.js\nwindow.__ccxTokenizer"]
vendor["vendor/gpt-tokenizer/*"]
core["content/core/*"]
ui["content/ui/*"]
content["content.js\ncomposition root"]
background["background.js"]
manifest --> config
manifest --> namespace
manifest --> registry
manifest --> estimators
manifest --> tokenizer
manifest --> vendor
manifest --> core
manifest --> ui
manifest --> content
manifest --> background
namespace --> core
namespace --> ui
estimators --> registry
vendor --> tokenizer
registry --> content
tokenizer --> content
config --> content
core --> content
ui --> content
content -. "chrome.runtime.sendMessage\nccx-open-learn" .-> background