Categories

Array Filter

Filter out elements of specific types from arrays (remove numbers, strings, booleans, etc.)

Key Facts

Category
Data Processing
Input Types
textarea, select, checkbox, text
Output Type
text
Sample Coverage
4
API Ready
Yes

Overview

The Array Filter tool allows you to quickly clean and refine your data by removing specific element types from arrays, such as integers, floats, strings, or boolean values.

When to Use

  • When you need to sanitize raw data by stripping out unwanted data types before processing.
  • When you have mixed-type arrays and need to isolate specific values for analysis.
  • When preparing JSON datasets for API integration by removing null or undefined entries.

How It Works

  • Paste your array into the input field using JSON format, comma-separated values, or one item per line.
  • Select the specific data type you wish to remove from the 'Filter Type' dropdown menu.
  • Adjust optional settings like 'Include Null Values' or 'Trim Whitespace' to refine your output.
  • Click the process button to generate your cleaned array instantly.

Use Cases

Cleaning API responses that contain mixed data types.
Preparing numeric datasets for mathematical operations by removing stray strings.
Filtering out boolean flags from configuration arrays.

Examples

1. Removing Strings from a Mixed Dataset

Data Analyst
Background
I have a list of sensor readings that accidentally includes error messages as strings.
Problem
I need to extract only the numeric values to perform statistical analysis.
How to Use
Input the mixed array, select 'Remove Strings' from the filter type, and process.
Example Config
filterType: 'strings'
Outcome
The tool returns a clean array containing only the numeric sensor readings.

2. Sanitizing Configuration Arrays

Web Developer
Background
I have a configuration array that contains boolean flags and integers, but I only need the integers.
Problem
The boolean values are causing type-mismatch errors in my application logic.
How to Use
Paste the array and select 'Remove Booleans' to strip the true/false values.
Example Config
filterType: 'booleans'
Outcome
A refined array containing only the necessary integer configuration values.

Try with Samples

video, text, barcode

Related Hubs

FAQ

What input formats does this tool support?

You can provide data as a standard JSON array, comma-separated values, or by placing each element on a new line.

Can I remove multiple types at once?

Currently, the tool processes one filter type at a time to ensure precise data cleaning.

Does this tool handle nested arrays?

This tool is designed to filter elements within a single-level array.

Is the filtering case-sensitive for strings?

Yes, you can toggle the 'Case Sensitive' option to control how string filtering is applied.

What happens to null or undefined values?

You can choose to keep or remove null and undefined values using the dedicated checkboxes in the configuration settings.

API Documentation

Request Endpoint

POST /en/api/tools/array-filter

Request Parameters

Parameter Name Type Required Description
inputArray textarea Yes -
filterType select Yes -
includeNull checkbox No -
includeUndefined checkbox No -
caseSensitive checkbox No -
trimWhitespace checkbox No -
customSeparator text No -

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-array-filter": {
      "name": "array-filter",
      "description": "Filter out elements of specific types from arrays (remove numbers, strings, booleans, etc.)",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=array-filter",
      "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]