LaTeX Word Counter

created by Affan :)

LaTeX mode

About this tool

Existing word counting solutions are poorly suited to LaTeX documents. General-purpose counters process raw source as plain text, producing inflated totals that include commands, preamble declarations, and environment syntax. TeXcount and Overleaf's built-in counter offer greater accuracy but present their own limitations: Overleaf's default "Total Words" counts only body text as interpreted by TeXcount, systematically excluding bibliography entries, citations, captions, and footnotes. TeXcount itself can be configured to include these elements, but doing so requires modifying command-line flags or compilation settings — a process that introduces friction disproportionate to the task of checking a document against a word limit.

This tool was developed to provide a purpose-built alternative. It performs single-pass parsing of LaTeX source entirely within the browser, requiring no server, no compilation step, and no external dependencies. The parser identifies and classifies the full structure of a .tex file: preamble content, sectioning commands, citation keys, figure captions, table environments, footnotes, mathematical expressions, and bibliography entries. Each element is assigned a typed token, and the word count is computed from whichever categories the user has toggled on. A colour-coded verbose view offers full transparency over every classification decision.

A plain text mode is also available for counting essays and other documents not written in LaTeX. In plain text mode every word is counted without LaTeX parsing, and the structure tab shows word counts per paragraph.

Affan · Land Economy Tripos · University of Cambridge

Privacy

All word counting happens entirely within the browser. No LaTeX source is transmitted, uploaded, or stored on any server at any point. The tool runs as a self-contained HTML file, so document content never leaves the machine it is opened on.

The site uses Umami for anonymous, cookie-free analytics. Umami collects only aggregate usage data such as page views and visitor counts — it does not track individual users, does not use cookies, and does not collect any personal information or document content.

The entire source code is visible and open-source (MIT License). Any preferences you set (such as dark mode or toggle states) are stored only in your browser's local storage and are never transmitted.

Getting started

Paste your entire .tex file into the text area — preamble, \begin{document}, bibliography and all. The counter automatically strips the preamble and parses the rest. Press Count Words or Ctrl+Enter.

LaTeX mode vs Plain text mode

By default the tool is in LaTeX mode, where commands, environments, and % comments are parsed and classified. This is what you want for .tex source files.

If you are counting a plain essay or any document not written as LaTeX source — for example, a Word document pasted as plain text — use the Change to plain text toggle beside the input area. In plain text mode every word is counted without any LaTeX interpretation: % signs, backslashes, and curly braces are treated as ordinary characters. Switch back with Change to LaTeX source.

Word limit

If your assignment has a word limit, enter it in the Word Limit field. A progress bar will show your count, percentage, and signed difference. The bar turns red if you exceed the limit.

Toggles (LaTeX mode only)

Citations
Each \cite-family command counts as 1 word per citation key.
Figure captions
All text inside \begin{figure}...\end{figure} environments.
Tables
All text inside table, tabular, tabularx, and longtable environments.
Footnotes
Text inside \footnote{} commands.
Mathematics
Display math and inline math. Each variable, number, or symbol command counts as 1 word.
Headings
The text inside \section{}, \subsection{}, and \subsubsection{} commands.
Abstract
All text inside \begin{abstract}...\end{abstract} environments.
Bibliography
Everything inside \begin{thebibliography}...\end{thebibliography}.

Tabs

Summary
Categorised word counts, progress bar (if word limit is set), and keyword density for the 20 most frequent non-trivial words. In plain text mode only the total and keywords are shown.
Structure
LaTeX mode: a hierarchical breakdown by section. Plain text mode: word counts per paragraph (separated by blank lines).
Verbose
Your full document with colour highlighting. In LaTeX mode you can switch between Included / Excluded (word-by-word green/red chips showing exactly what counts) and Categories (every token coloured by type). In plain text mode only the Included / Excluded view is available.

Changelog

v1.4 — 24 Feb 2026
  • Replaced “Target” label with “Word Limit”
  • Verbose view now defaults to Included / Excluded; Categories available as secondary view
  • Fixed verbose view lag when switching modes — rendering uses requestAnimationFrame with render guard
  • Fixed toggle-induced lag and crashes in verbose view via improved debouncing
  • Toggle grid now displays as a 4×2 layout for even spacing
  • Dark mode scrollbar styling for textarea and verbose view
  • Mode indicator now uses high-contrast green styling
  • Changelog entries are now collapsible — click version headers to expand
  • Removed colour reference table from “How this works” for brevity
  • Dark mode verbose highlighting updated with subtle neon-style colours
v1.3 — 21 Feb 2026
  • Fixed dash-separated words (e.g. “subgroups---engaged”) now correctly count as separate words
  • Plain text mode now excludes all punctuation (except within numbers) from word tokens
  • Fixed Include/Exclude toggle lag and crash — toggle updates are now debounced
  • Improved paragraph detection: paragraphs are identified by line breaks, not just double blank lines
  • Fixed crash when switching modes with text already present
  • Swapped mode indicator and change-mode button positions; change-mode button now uses green text
  • Added Umami event tracking to all interactive buttons on the page
v1.2 — 21 Feb 2026
  • Fixed verbose view lag when switching between Categories and Included/Excluded modes
  • Moved mode indicator to header area for cleaner layout
  • Added stale content warning when text is edited after counting
  • Fixed header buttons layout to remain stable across mode switches
v1.1 — 21 Feb 2026
  • Plain text mode — count essays and non-LaTeX documents; toggle sits beside the input label
  • Included / Excluded verbose view now highlights each word individually
  • Help panels auto-close when another is opened
  • Fixed mobile emoji rendering for dark mode toggle
  • Verbose mode switching no longer crashes on rapid toggling
v1.0 — 20 Feb 2026
  • Single-pass LaTeX parser with token classification
  • Toggleable categories: citations, captions, tables, footnotes, math, headings, abstract, bibliography
  • Hierarchical structure breakdown with collapsible section tree
  • Dual-mode verbose view: category colours and included/excluded
  • Keyword density analysis (top 20 words)
  • Progress bar with percentage and signed difference
  • Dark mode, zoom slider, fully offline

Report a bug

If you encounter unexpected behaviour, an incorrect word count, or a parsing error, please report it so it can be fixed.

Issue tracker: github.com/dziyaulaffan/latexwordcounter/issues

When reporting, it helps to include the LaTeX source (or a minimal example) that produces the incorrect result, the expected word count, and which toggles were active.

All counting happens locally in your browser. Your LaTeX is not uploaded or stored.
13px
Content has changed since last count. Press Count Words or Ctrl+Enter to update.
Body text0
Citations0
Captions0
Tables0
Footnotes0
Math words0
Headings0
Abstract0
Bibliography0
Math expressions0
Total counted words0
Included
Excluded