Overview
Introduction
Spotting every use of a specific word across a long document by eye is slow and unreliable, especially for a common word.
It runs entirely client-side, so nothing you paste is ever uploaded to a server.
What Is Word Highlighter?
A word highlighter that wraps every whole-word occurrence of a chosen word, matched case-insensitively, with a marker string on both sides.
It runs entirely client-side as part of this site's String Tools collection, so nothing you paste is ever uploaded to a server.
How Word Highlighter Works
The target word is escaped for safe regex use and matched with word-boundary anchors on both sides, case-insensitively, and each match is wrapped in the marker string via a capturing group.
The transformation happens synchronously in JavaScript the moment you type, with no network round trip involved.
When To Use Word Highlighter
Use it to check keyword usage in a draft, proofread for an overused word, or prepare a passage for a highlight-style export.
It's a fast way to get the answer without opening a code editor, a REPL, or writing a one-off script just to check.
Often used alongside Letter Highlighter and Multi-Pattern Highlighter.
Features
Advantages
- Word-boundary matching avoids false positives inside longer words.
- Works with any marker string, from Markdown bold to custom brackets.
- Captures the matched word and reinserts it, so the original capitalization survives even though matching itself ignores case.
Limitations
- Highlights one target word per run; different inflections of a word need to be run separately.
- Applies word boundaries strictly, so a hyphenated or apostrophised form counts as a different word and is left unmarked.
Examples
Best Practices & Notes
Best Practices
- Run the tool once per distinct word or inflection you want to mark, since matching is exact per word form.
- Choose a marker that does not already appear in the text, otherwise the highlights become impossible to pick out reliably.
- Run it over a draft to check for an overused word, counting the markers rather than trying to spot repetition by eye.
Developer Notes
The regex is built as `new RegExp(`\\b(${escaped})\\b`, "gi")` with the target word captured in group 1, so the replacement `${marker}$1${marker}` reinserts the originally-cased matched text rather than the lowercase search term.
Word Highlighter Use Cases
- Checking keyword usage or density in a draft
- Proofreading for an overused word
- Preparing text for a highlight-style export or presentation
Common Mistakes
- Expecting substrings inside longer words to be matched.
- Trying to highlight multiple unrelated words in one run.
Tips
- Use the Multi-Pattern Highlighter instead when you need to mark several different words in the same pass.
- Because the match is anchored on both sides, searching for 'the' will not mark 'there' or 'other', which is exactly what makes it useful for proofreading.