Array Utilities

Array Partition

Splits arrays into equally-sized chunks with configurable handling for remainders. Use via MCP in Cursor or Windsurf, or call GET /v1/array/partition with your array and chunk size. Perfect for pagination, batch processing, or data visualization where you need [1,2,3,4,5,6] → [[1,2], [3,4], [5,6]] transformations. Returns consistent JSON structure regardless of input size.

API Endpoint

GET /v1/array/partition

Code Examples

curl "https://tinyfn.io/v1/array/partition" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/partition', {
  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/partition',
    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 array tools:

{
  "mcpServers": {
    "tinyfn-array": {
      "url": "https://tinyfn.io/mcp/array",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I partition an array into chunks of 3 elements each?

Send a GET request to /v1/array/partition with your array and size=3. For [1,2,3,4,5,6,7], you'll get [[1,2,3], [4,5,6], [7]].

What happens to leftover elements that don't fill a complete chunk?

The final chunk contains the remaining elements even if smaller than the specified size. Array [1,2,3,4,5] with size=2 returns [[1,2], [3,4], [5]].

Can MCP tools like Cursor automatically partition arrays during code generation?

Yes, AI agents in Cursor and other MCP-enabled editors can call this tool to partition data structures, especially useful for generating pagination logic or batch processing code.

What's the maximum array size this partition tool can handle?

The tool handles arrays within reasonable REST API limits, typically thousands of elements. For massive datasets, consider client-side chunking before API calls.

How is this different from array splitting at specific indices?

This partitions by uniform chunk size, not at specific positions. Use array split tools if you need to break at exact indices rather than equal-sized segments.

Try Array Partition Now

Get your free API key and start using Array Partition in seconds.

Get Free API Key