# Remove By Predicate

Remove items that match a predicate using lodash _.remove

> Canonical page: https://elysiatools.com/en/tools/remove-by-predicate

- **Category:** Data Processing

- **Keywords:** array, remove, predicate, filter, lodash

## Overview

Remove items from an array when they match the selected predicate.

**Highlights:**
- Uses lodash `_.remove`
- Supports numeric and string comparisons
- Returns the remaining array as JSON

**Example:**
- Array: `[1, 2, 3, 4]`
- Predicate: `greater-than`
- Compare: `2`
- Result: `[1, 2]`

## Inputs

- **Array** (textarea): Enter a JSON array
- **Predicate Type** (select): Select the condition for removal
- **Compare Value** (text): Value to compare against (required for most predicates)

## When to use

- When you need to remove specific items from an array based on a condition like greater-than or string-contains.
- For data cleaning tasks, such as eliminating outliers, null values, or invalid entries from datasets.
- To preprocess arrays before further analysis, transformation, or integration into other workflows.

## How it works

- Input a valid JSON array in the provided text area.
- Select a predicate type from the dropdown, such as 'greater-than' or 'string-contains'.
- Enter a compare value if required by the predicate (e.g., a number or string).
- The tool processes the array using lodash _.remove and outputs the filtered array as JSON.

## Use cases

- Cleaning data by removing null, undefined, or falsey values from an array.
- Filtering numerical lists to exclude values outside a specified range, such as removing outliers.
- Selecting strings that contain, start with, or end with specific substrings for text processing tasks.

## Frequently asked questions

### What predicates are supported?

The tool supports predicates like less-than, greater-than, equals, not-equals, string-contains, string-starts-with, string-ends-with, is-nullish, is-truthy, and is-falsey.

### Is the compare value always required?

No, for predicates like is-nullish, is-truthy, or is-falsey, the compare value is not needed.

### Can I use this tool with arrays of objects?

The tool is designed for arrays of primitive values like numbers or strings. For objects, extract specific properties first.

### What happens if the array is empty?

The tool will return an empty array as the result, with no elements removed.

### Does the tool modify the original array?

No, it returns a new array with matching elements removed, leaving the original input unchanged.

## Related tools

- [Uniq With](https://elysiatools.com/en/tools/uniq-with): Remove duplicates using lodash _.uniqWith and deep equality
- [Compact Array](https://elysiatools.com/en/tools/compact-array): Remove falsey values from array using lodash _.compact
- [Drop Items](https://elysiatools.com/en/tools/drop-items): Drop first N items from array using lodash _.drop
- [Drop Right Items](https://elysiatools.com/en/tools/drop-right-items): Drop last N items from array using lodash _.dropRight
- [Pull Values](https://elysiatools.com/en/tools/pull-values): Remove specific values from an array using lodash _.pull
- [Sorted Unique](https://elysiatools.com/en/tools/sorted-unique): Remove duplicates from a sorted array using lodash _.sortedUniq
- [Sorted Unique By](https://elysiatools.com/en/tools/sorted-unique-by): Remove duplicates from a sorted array using lodash _.sortedUniqBy
- [Uniq Array](https://elysiatools.com/en/tools/uniq-array): Remove duplicates from an array using lodash _.uniq

## Samples

- [Grafana Advanced Application Samples](https://elysiatools.com/en/samples/grafana-samples): Comprehensive Grafana samples covering advanced dashboard design, alerting configurations, data source integrations, and plugin development
- [QR Code Samples](https://elysiatools.com/en/samples/qrcode-samples): Sample QR code images for testing QR code reading and generation tools
- [D3.js Data Visualization Samples](https://elysiatools.com/en/samples/d3js-data-visualization): Comprehensive D3.js data visualization examples including charts, maps, animations, and interactive visualizations
- [Rome JavaScript Toolchain Samples](https://elysiatools.com/en/samples/rome): Rome JavaScript toolchain examples including configuration, linting, formatting, bundling, and project management
