Group By Length organizes array items by their string length, returning a map where keys are lengths and values are arrays of matching items. Use via MCP in Cursor or Windsurf, or call GET /v1/array/group-by-length directly. Perfect for text analysis, data categorization, or preparing datasets where string length matters for processing logic.
curl "https://tinyfn.io/v1/array/group-by-length" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/group-by-length', {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get('https://tinyfn.io/v1/array/group-by-length',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's array tools:
{
"mcpServers": {
"tinyfn-array": {
"url": "https://tinyfn.io/mcp/array",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}
It converts all items to strings first, then groups by the resulting string length. Numbers, booleans, and objects get stringified before length calculation.
Returns a JSON object with string length as keys and arrays of matching items as values, like {"3": ["cat", "dog"], "4": ["bird"]}.
Yes, it's excellent for categorizing form inputs, analyzing password lengths, or grouping search queries by character count in AI agent workflows.
Yes, items maintain their original array order within each length group, making results predictable and consistent.
Empty strings group under length "0", while null/undefined values are converted to strings ("null"/"undefined") and grouped by their string representation length.
Get your free API key and start using Group By Length in seconds.
Get Free API Key