String find statistics
Count a string's occurrences and report its first position and query length.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Find statistics
Shows matches and the first position.
Enter text and a query to calculate statistics
Occurrences: 0 · Query length: 0 · First index: 0
What this tool does
- Count how many times a keyword appears in a block of text and where it first shows up — more reliable than counting by eye when proofreading.
- Debug “I can see two hits but the tool reports one”: overlapping matches are counted by default, so `aa` occurs 3 times in `aaaa`; uncheck the option to switch to non-overlapping counting and get 2.
- Case is ignored by default (both sides are lower-cased), so `test` occurs twice in `Test test`; uncheck it for a case-sensitive count that leaves only the hit at index 5.
- Use the first index to locate the hit: indexes are JavaScript string offsets starting at 0, for example `world` sits at 6 in `hello world`.
Example
Input
banana
Output
2 occurrences
The query `ana` matches twice in `banana` (indexes 1 and 3, overlapping), so the output is `2 occurrences`; the stats line also reports 2 occurrences, a query length of 3 and a first index of 1.
Frequently asked questions
Are overlapping matches counted by default?
Yes — `ana` matches twice in `banana`, and `aa` matches 3 times in `aaaa`. For the more usual “skip past each match” behaviour (2 hits for `aa` in `aaaa`), uncheck “Count overlapping matches”.
How is the position measured?
As a JavaScript string index starting at 0, counted in UTF-16 code units: `world` is at 6 in `hello world`. That means an emoji such as 🌊 (two code units) shifts every later index by one, while the query length is counted in code points (🌊 = 1) — the two numbers use different units on purpose.
Is the query a regular expression?
No. This is a literal search, so `.*` or `\d` are treated as ordinary characters. Use a regex-capable tool when you need patterns; this one never rewrites your text.
What happens with an empty query or empty text?
An empty query is rejected (you get “invalid text, query or options”), because an empty string would match at every position and the count would be meaningless. Empty text, or a query that never occurs, is fine and reports `0 occurrences` with a first index of -1.
How is letter case handled?
Case is ignored by default: both sides are lower-cased first with `toLocaleLowerCase()`, so `test` matches twice in `Test test`. Turn “Ignore case” off for an exact comparison, which leaves only the occurrence at index 5. Locale-specific casing (Turkish dotted/dotless i, for instance) can differ from what you expect.
Keywords:string searchoccurrence countfind statisticstext tool