LiveLOC — Live Line Counter, Token Meter & Code Stats for VS Code
A live lines-of-code and token counter for VS Code. Two counters in your status bar — current file and whole workspace — updating on every keystroke. Includes an AI Context Meter that shows how your code fits against Claude, GPT-5, and Gemini context windows, with live cost estimates. A lightweight in-editor alternative to cloc / sloc.


Why LiveLOC?
- Live — counts update on every keystroke, not on save
- Two counters, one glance — current file and whole-workspace LOC + tokens in the status bar
- AI Context Meter — visual fit bars against every major model's context window, with cost estimates
- Project stats without leaving the editor — per-language LOC and token breakdown on click
- Honest counting — skips binaries, respects
files.exclude / search.exclude, configurable size cap
Common names people search for this kind of tool: line counter, token counter, line count, lines of code, LOC counter, SLOC, CLOC, tiktoken, Claude tokens, GPT tokens, Gemini tokens, context window, AI cost, code statistics, code metrics, project stats, file stats. LiveLOC covers all of these in a single, zero-config status-bar widget.
AI Context Meter
Click the workspace counter (or use the LiveLOC: Show AI Context Meter command) to open a visual fit-meter for your code:
$(pulse) LiveLOC — AI Context Meter
─────────────────────────────────────────────────────────
Workspace · ~42,180 tokens 3,290 LOC across 47 files
─────────────────────────────────────────────────────────
Anthropic
✓ Claude Opus 4.7 1M ctx ██░░░░░░░░░░░░ 4% · ~$0.63
✓ Claude Sonnet 4.6 1M ctx ██░░░░░░░░░░░░ 4% · ~$0.13
✓ Claude Sonnet 4.5 200K ctx ███░░░░░░░░░░░ 21% · ~$0.13
✓ Claude Haiku 4.5 200K ctx ███░░░░░░░░░░░ 21% · ~$0.04
OpenAI
✓ GPT-5.4 272K ctx ██░░░░░░░░░░░░ 15% · ~$0.10
✓ GPT-5 272K ctx ██░░░░░░░░░░░░ 15% · ~$0.05
✓ GPT-4o 128K ctx █████░░░░░░░░░ 33% · ~$0.10
Google
✓ Gemini 3.1 Pro 2M ctx █░░░░░░░░░░░░░ 2% · ~$0.08
✓ Gemini 2.5 Pro 1M ctx ██░░░░░░░░░░░░ 4% · ~$0.05
The token count is estimated via a character-based heuristic (~3.5 chars/token), which lands within ~10–15% of OpenAI's o200k_base tokenizer on typical source code. We keep the heuristic local and tiny rather than bundling a 2 MB BPE table — the extension stays under 50 KB and never makes a network call. Numbers are prefixed with ~ to signal estimation.
If no workspace is open, the meter falls back to measuring the active file.
Features
- Current-file counter on the bottom-right; updates on every keystroke
- Workspace counter on the bottom-left; recounts on save, create, delete, or rename
- Token counts (heuristic) shown alongside LOC for both file and workspace
- AI Context Meter quick-pick: visual fit bars + cost estimates for Claude, GPT, Gemini
- Selection-aware — highlight code and the file counter shows
selected / total for both LOC and tokens
- Session delta on the workspace counter (
↑47 / ↓12 since the editor opened)
- Per-language breakdown when you click the workspace counter — now includes tokens per language
- Editor title bar buttons for both the breakdown and the context meter
- Honors your
files.exclude and search.exclude settings — no duplicate config
What you'll see
| Status bar text |
Meaning |
3,290 LOC · ~42k tok ↑47 |
Workspace total: 3,290 lines / ~42k tokens, +47 lines this session |
3,290 LOC · ~42k tok (spinner) |
Workspace is currently re-scanning |
142 LOC · ~1.2k tok |
Current file: 142 lines, ~1,200 tokens |
42 / 142 LOC · 380 / ~1.2k tok |
42 lines (380 tokens) selected out of 142 lines / ~1.2k tokens |
Commands
| Command |
What it does |
LiveLOC: Show AI Context Meter |
Visual fit against Claude / GPT / Gemini context windows + cost |
LiveLOC: Show Workspace Breakdown |
Per-language LOC and token quick-pick |
LiveLOC: Toggle Counting of Blank Lines |
Include or exclude blank lines from all counts |
LiveLOC: Refresh Workspace Scan |
Force a fresh re-scan |
LiveLOC: Reset Session Baseline |
Resets the session delta to zero |
LiveLOC: Show Current File Details |
Notification: lines, tokens, words, characters, language |
LiveLOC: Show Logs |
Opens the output channel for diagnostics |
Settings
| Setting |
Default |
Description |
liveloc.includeBlankLines |
false |
Count blank lines toward the total |
liveloc.showFile |
true |
Show the current-file count in the status bar |
liveloc.showWorkspace |
true |
Show the workspace-wide count in the status bar |
liveloc.showTokens |
true |
Show estimated token counts alongside LOC |
liveloc.maxFileSizeKB |
5120 |
Skip files larger than this during workspace scans |
liveloc.exclude |
(list) |
Glob patterns to exclude from workspace scanning |
Install
From a local .vsix:
npm install
npm run build
npm run package
Then in VSCode: Extensions → ⋯ → Install from VSIX…
Develop
git clone https://github.com/nijil71/LiveLOC.git
cd LiveLOC
npm install
npm run watch
Press F5 to launch an Extension Development Host with LiveLOC loaded.
How counting works
Lines
- Lines are split on
\r\n, \r, and \n.
- A trailing empty line at end-of-file is not counted.
- With
includeBlankLines: false (default), lines that are empty after trimming are excluded.
- Binary files are skipped via a null-byte heuristic on the first 8 KB.
- Files over
maxFileSizeKB (default 5 MB) are skipped.
Counting is line-based, not token-based — comments are included as code lines.
Tokens
Tokens are estimated using a character-based heuristic (Math.round(chars / 3.5)), which lands within ~10–15% of OpenAI's o200k_base BPE tokenizer on typical source code. We chose this over bundling a real tokenizer because the encoding tables alone are ~2 MB — for a status-bar widget, that's a 200× size hit. Numbers are always prefixed with ~ to make the approximation explicit. Cost estimates use published per-million-token input pricing for each model (as of May 2026).
License
MIT — see LICENSE.