JSON Utilities

Get Keys

Extracts all top-level keys from a JSON object as an array. Use via MCP in Cursor or Windsurf, or call GET /v1/json/keys with your JSON payload. Returns ["name", "age", "city"] from {"name": "Alice", "age": 30, "city": "NYC"}. Only processes the immediate keys, not nested objects.

API Endpoint

GET /v1/json/keys

Code Examples

curl "https://tinyfn.io/v1/json/keys" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/json/keys', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/json/keys',
    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 json tools:

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

Learn more about MCP setup →

FAQ

How do I get keys from a JSON object using MCP?

Call the get_keys tool with your JSON object. It returns an array of all top-level property names.

Does JSON keys extraction work with nested objects?

Only returns immediate top-level keys. For nested objects like {"user": {"profile": {}}}, you get ["user"], not the inner keys.

What happens if I pass an empty JSON object?

Returns an empty array []. Arrays and primitive values return empty arrays since they have no object keys.

Can I get keys from JSON arrays?

Arrays don't have named keys, so the tool returns an empty array. Use this specifically for JSON objects with key-value pairs.

How is this different from Object.keys() in JavaScript?

Identical behavior to Object.keys() but deterministic and accessible to AI agents via MCP without code execution risks.

Try Get Keys Now

Get your free API key and start using Get Keys in seconds.

Get Free API Key