Array Compact filters out falsy values like null, undefined, empty strings, 0, and false from arrays. Access via MCP in Cursor or Windsurf, or REST at GET /v1/array/compact. Pass ["hello", "", null, "world", 0] and get ["hello", "world"] back. Deterministic filtering ensures consistent results across AI agent workflows.
curl "https://tinyfn.io/v1/array/compact" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/compact', {
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/compact',
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"
}
}
}
}
Removes all falsy values: null, undefined, false, 0, empty strings (""), and NaN. Keeps truthy values including non-empty strings, numbers > 0, objects, and arrays.
Call the array_compact function with your array parameter. The MCP tool handles the REST API call and returns the cleaned array directly in your AI workflow.
Only removes falsy primitive values at the top level. Objects and nested arrays are preserved intact, even if they contain falsy properties internally.
Array compact specifically removes falsy values using JavaScript's truthiness rules. Filter requires custom logic and predicates for each use case.
Yes, works with any JavaScript array containing mixed primitives, objects, or arrays. Only falsy primitives are removed regardless of other element types.
Get your free API key and start using Array Compact in seconds.
Get Free API Key