String Utilities

Word Count

Counts words in any text string with precise, deterministic results. Use via MCP in Cursor or Windsurf, or call GET /v1/string/word-count directly. Returns exact word count using standard whitespace delimiters — "hello world" gives 2, empty string gives 0. Perfect for content analysis and validation in AI workflows.

API Endpoint

GET /v1/string/word-count

Code Examples

curl "https://tinyfn.io/v1/string/word-count" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/string/word-count', {
  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/word-count',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

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"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How does TinyFn count words compared to other tools?

TinyFn uses standard whitespace delimiters (spaces, tabs, newlines) to split text into words. It's deterministic and consistent, unlike some tools that handle punctuation differently.

Can I count words in large text files with the MCP tool?

Yes, the MCP tool in Cursor, Claude Code, and other editors can process large text blocks. There's no practical limit for typical document analysis tasks.

What happens with punctuation and special characters?

Words with attached punctuation count as single words. "Hello, world!" counts as 2 words, not 4. Standalone punctuation marks are ignored.

Does the word count tool handle multiple languages?

Yes, it works with any UTF-8 text including non-Latin scripts. However, it uses space-based splitting which works best for space-separated languages.

How do I integrate word counting into my AI agent workflow?

Use it via MCP for real-time counting in your IDE, or call the REST API programmatically. Great for content validation, text processing pipelines, and document analysis.

Try Word Count Now

Get your free API key and start using Word Count in seconds.

Get Free API Key