JSON Utilities

Flatten Json

Converts nested JSON objects into flat key-value pairs using dot notation. Access via MCP in Cursor or Windsurf, or call GET /v1/json/flatten with your JSON payload. Perfect for processing complex API responses or preparing data for databases that don't handle nested structures. Returns deterministic flattening with configurable separators.

API Endpoint

GET /v1/json/flatten

Code Examples

curl "https://tinyfn.io/v1/json/flatten" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/json/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/json/flatten',
    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 does JSON flattening work with nested objects and arrays?

Nested objects become dot-separated keys like 'user.profile.name', while arrays use bracket notation like 'items[0].value' or numeric indices depending on configuration.

Can I customize the separator used in flattened JSON keys?

Yes, you can specify custom separators instead of the default dot notation, useful when integrating with systems that have key naming restrictions.

How do MCP tools like Claude Code handle large JSON objects for flattening?

MCP tools process JSON flattening deterministically regardless of size, though very deep nesting may hit practical limits depending on the AI agent's context window.

What happens to null values and empty objects during flattening?

Null values are preserved as null in the flattened output, while empty objects and arrays can be optionally included or omitted based on configuration.

Is flattened JSON reversible back to the original nested structure?

Yes, flattened JSON using standard dot notation can typically be reconstructed, though some edge cases with special characters in keys may require careful handling.

Try Flatten Json Now

Get your free API key and start using Flatten Json in seconds.

Get Free API Key