惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
博客园 - Franky
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
爱范儿
爱范儿
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
Microsoft Security Blog
Microsoft Security Blog
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I Built an AI Token Calculator Because Long Prompts Need ...
Zley · 2026-05-07 · via DEV Community

Zley

I keep running into the same small problem when working with LLMs: a prompt looks fine in a text editor, but I still need to know whether it is going to fit inside the model context window before I send it.

That is why I added a new tool to Tools Online: AI Token Calculator.

It is a browser-based token and context estimator for common AI models. You can paste a prompt, code snippet, document section, or chat draft, pick the provider/model you care about, and see the token count plus context usage immediately.

What it supports

The first version focuses on the models I most often need to plan for:

  • OpenAI / GPT models
  • Claude
  • Gemini
  • Qwen
  • GLM
  • Kimi

For OpenAI models, the tool uses compatible local BPE tokenizers. For the other providers, it shows the result as a local estimate because their exact billing tokenizers are either proprietary or exposed through authenticated APIs.

That distinction is intentional. I did not want the UI to pretend every number has the same precision. If the result is exact, it is marked as exact. If it is an estimate for planning, it is marked as an estimate.

No API key, no upload

The part I cared about most was privacy. Prompt drafts often contain product ideas, customer text, logs, or internal notes. I did not want a token calculator that sends that text to another server just to produce a rough number.

So the calculator runs in the browser and does not require an API key. You paste text, choose the model, and get a quick read on whether the prompt is small, close to the limit, or already too large.

Where AI helped during development

AI was useful in the boring but important parts of the build. I used it to map out edge cases, compare how different providers expose token counting, shape the first version of the copy, and check whether the UI explained exact counting versus estimation clearly enough.

The final product still needed manual decisions: keep the tool simple, avoid implying exact billing numbers for proprietary tokenizers, support multiple languages, and make the context window usage obvious at a glance.

When I use it

This has already been useful before sending long prompts to production models, trimming documents for chat, checking code snippets, and estimating whether a multi-message prompt should be split.

If you work with GPT, Claude, Gemini, Qwen, GLM, or Kimi and want a quick local check before sending a prompt, you can try the AI Token Calculator here.