Flatten Depth Array
Flatten array to specified depth using lodash _.flattenDepth
Flatten an array up to a specified depth level (nesting flattened to the specified level).
## Features:
- Accepts deeply nested JSON arrays of any depth
- Customizable flatten depth (1-10 levels)
- Precise control over flattening level
- Handles arrays with mixed data types
- Uses lodash _.flattenDepth for controlled flattening
## Examples:
- Depth 1: [1, [2, [3, [4]]], 5] → [1, 2, [3, [4]], 5]
- Depth 2: [1, [2, [3, [4]]], 5] → [1, 2, 3, [4], 5]
- Depth 3: [1, [2, [3, [4]]], 5] → [1, 2, 3, 4, 5]
## Use Cases:
- **Controlled Transformation**: Flatten to a specific level while preserving deeper structure
- **Data Processing**: Process nested arrays level by level
- **Partial Flattening**: Reduce nesting without losing all structure
- **Progressive Operations**: Apply transformations at specific nesting levels
API Documentation
Request Endpoint
POST /en/api/tools/flatten-depth-array
Request Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| array | textarea | Yes | Enter a valid JSON array with deeply nested elements |
| depth | number | No | Number of levels to flatten (1-10) |
Response Format
{
"result": "Processed text content",
"error": "Error message (optional)",
"message": "Notification message (optional)",
"metadata": {
"key": "value"
}
}
Text:
Text
AI MCP Documentation
Add this tool to your MCP server configuration:
{
"mcpServers": {
"elysiatools-flatten-depth-array": {
"name": "flatten-depth-array",
"description": "Flatten array to specified depth using lodash _.flattenDepth",
"baseUrl": "https://elysiatools.com/mcp/sse?toolId=flatten-depth-array",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}
You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.
If you encounter any issues, please contact us at [email protected]