Compact Array
Remove falsey values from array using lodash _.compact
## Array Compaction Tool
This tool removes falsey values from arrays using Lodash's `_.compact` method.
**Falsey values removed:**
- `false`
- `null`
- `0`
- `""` (empty string)
- `undefined`
- `NaN`
**Example:**
```json
Input: [0, 1, false, 2, "", 3, null, 4, undefined, 5, NaN]
Output: [1, 2, 3, 4, 5]
```
**Options:**
- **Preserve Zeros**: Keep zero values in the array
- **Preserve Empty Strings**: Keep empty strings in the array
API Documentation
Request Endpoint
POST /en/api/tools/compact-array
Request Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| array | textarea | Yes | Enter a JSON array to compact |
| preserveZeros | checkbox | No | Keep zero (0) values in the array |
| preserveEmptyStrings | checkbox | No | Keep empty string ("") values in the array |
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-compact-array": {
"name": "compact-array",
"description": "Remove falsey values from array using lodash _.compact",
"baseUrl": "https://elysiatools.com/mcp/sse?toolId=compact-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]