Flatten Array converts nested arrays into a single-level array, removing all nesting regardless of depth. Access via MCP in Cursor or Windsurf, or call GET /v1/misc/flatten with your nested array data. Returns `[1,2,3,4,5]` from `[[1,2],[3,[4,5]]]`. Handles mixed data types and preserves original element order deterministically.
curl "https://tinyfn.io/v1/misc/flatten" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/misc/flatten', {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get('https://tinyfn.io/v1/misc/flatten',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's miscellaneous tools:
{
"mcpServers": {
"tinyfn-misc": {
"url": "https://tinyfn.io/mcp/misc",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}
Pass any nested array structure to the flatten endpoint — it handles unlimited nesting depth and preserves strings, numbers, booleans, and null values in their original order.
Yes, AI agents in Cursor or Claude Code can call this tool to normalize nested data structures before processing, especially useful for cleaning API responses or user input.
Absolutely — only the array structure changes. Numbers stay numbers, strings stay strings, and the relative order of all elements is maintained.
It returns the same array unchanged. The tool safely processes any input without errors, making it ideal for conditional flattening workflows.
This tool flattens to unlimited depth by default (like Array.flat(Infinity)), works server-side for any language, and provides consistent results across different environments.
Get your free API key and start using Flatten Array in seconds.
Get Free API Key