String Utilities

Count Char

Count Char tallies how many times a specific character appears in any string. Use it via MCP in Cursor or Windsurf, or call GET /v1/string/count-char with your text and target character. Perfect for data validation, parsing tasks, or analyzing text patterns. Returns an exact integer count, not an estimate.

API Endpoint

GET /v1/string/count-char

Code Examples

curl "https://tinyfn.io/v1/string/count-char" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/string/count-char', {
  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-char',
    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 do I count character occurrences in a string using MCP?

Call the count_char tool with your string and the character to count. It returns the exact number of matches, case-sensitive by default.

Does Count Char distinguish between uppercase and lowercase letters?

Yes, it's case-sensitive. Counting 'A' in 'Apple' returns 1, not 2. You'll need to normalize case beforehand if needed.

Can I count special characters like spaces, punctuation, or Unicode?

Absolutely. Count spaces, emojis, accented characters, or any single Unicode character. It handles the full Unicode range.

What's the REST API format for counting characters?

GET /v1/string/count-char with parameters for the input string and target character. Returns JSON with the count value.

How does Count Char help AI agents with text processing tasks?

Agents can validate input formats (counting digits), parse structured data (counting delimiters), or analyze text patterns without hallucinating counts.

Try Count Char Now

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

Get Free API Key