Counts how many times a substring appears in a string with optional case-insensitive matching. Access via MCP in Cursor or Windsurf, or REST at `/v1/string/count-substring`. Example: counting "cat" in "The cat sat on the cat mat" returns 2. Supports overlapping matches and Unicode strings.
curl "https://tinyfn.io/v1/string/count-substring" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/string/count-substring', {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get('https://tinyfn.io/v1/string/count-substring',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's string tools:
{
"mcpServers": {
"tinyfn-string": {
"url": "https://tinyfn.io/mcp/string",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}
Pass a case-insensitive flag parameter. The tool will convert both strings to lowercase before counting matches.
By default it finds non-overlapping matches. Some implementations offer an overlap flag to count overlapping occurrences like 'aa' appearing twice in 'aaa'.
Yes, it's perfect for counting error patterns, specific timestamps, or repeated events in log analysis workflows within AI coding assistants.
Empty substring typically returns 0 or error. Substring longer than main string returns 0 since no matches are possible.
Yes, it handles Unicode strings correctly, counting multi-byte characters and emojis as single units when they appear in the substring.
Get your free API key and start using Count Substring in seconds.
Get Free API Key