Array Utilities

Array Difference

Finds elements in the first array that don't exist in the second array. Use via MCP in Cursor or Windsurf, or call GET /v1/array/difference with JSON arrays. Returns [1,3] when comparing [1,2,3] against [2,4]. Performs exact value matching using JavaScript's includes() method for reliable set operations.

API Endpoint

GET /v1/array/difference

Code Examples

curl "https://tinyfn.io/v1/array/difference" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/difference', {
  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/difference',
    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 does array difference work with duplicate values?

It preserves duplicates from the first array. If array1 has [1,1,2] and array2 has [2], the result is [1,1].

What's the difference between array difference and array intersection?

Difference returns items in array1 NOT in array2, while intersection returns items present in BOTH arrays.

Can I use array difference in MCP tools for data filtering?

Yes, it's perfect for filtering datasets in Cursor or Claude Code. Compare user lists, remove processed items, or exclude blacklisted values.

How does it handle different data types in arrays?

Uses strict equality comparison. Numbers, strings, and booleans work reliably, but objects are compared by reference, not content.

What happens with empty arrays in difference operations?

Empty first array returns empty result. Empty second array returns the complete first array since nothing gets excluded.

Try Array Difference Now

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

Get Free API Key