> ## Documentation Index
> Fetch the complete documentation index at: https://docs.odella.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Filter Block

> Filter an array based on boolean conditions

<Frame>
  <img src="https://mintcdn.com/odella/I7v1Fbrp2kx7rLoj/block-reference/assets/filter_light.png?fit=max&auto=format&n=I7v1Fbrp2kx7rLoj&q=85&s=cd9cb3f0d7619da8e6499f87a3a02f2f" alt="Filter Block Screenshot" className="block dark:hidden" width="716" height="364" data-path="block-reference/assets/filter_light.png" />

  <img src="https://mintcdn.com/odella/I7v1Fbrp2kx7rLoj/block-reference/assets/filter_dark.png?fit=max&auto=format&n=I7v1Fbrp2kx7rLoj&q=85&s=843d84d31e3e736a7e7d9b79d2d9e197" alt="Filter Block Screenshot" className="hidden dark:block" width="714" height="348" data-path="block-reference/assets/filter_dark.png" />
</Frame>

## Overview

The Filter Block allows you to filter an array based on a corresponding array of boolean values. It takes an array of any data type and an array of boolean values of the same length, then outputs a new array containing only the elements where the corresponding boolean value is `true`.

This block is particularly useful for filtering arrays based on specific conditions, especially when combined with other blocks like [Compare](/block-reference/logic/compare) in a batched operation.

## Inputs

<ParamField path="array" type="any[]" required>
  The array to be filtered. Non-array inputs will be coerced into an array.
</ParamField>

<ParamField path="include" type="boolean[]" required>
  An array of boolean values indicating whether to include each element in the array. The length of this array should match the length of the array input.
</ParamField>

## Outputs

<ResponseField name="filtered" type="any[]">
  The filtered array, containing only the elements where the corresponding boolean value in the include input was `true`. The output maintains the data type of the input array.
</ResponseField>

## Example: Filter numbers greater than 3

1. Create an Array Block with values `[1, 2, 3, 4, 5]`.
2. Add a Compare Block, set comparison to `>`, and enable batching.
3. Create a Number Block with value `3`.
4. Connect the Array Block to Compare Block's `A` input, and Number Block to `B` input.
5. Add a Filter Block, connect Array Block to `array` input and Compare Block's `Result` to `include` input.
6. Run the flow. The Filter Block's `filtered` output should be `[4, 5]`.

## Error Handling

The Filter Block will error if:

* The `array` or `include` inputs are not provided
* The lengths of the input arrays do not match

## FAQ

<AccordionGroup>
  <Accordion title="What happens if the lengths of the array and include inputs do not match?">
    The Filter Block will error. The lengths of the array and include inputs should always match.
  </Accordion>

  <Accordion title="Can I use the Filter Block to filter an array of objects?">
    Yes, you can use the Filter Block to filter an array of any data type, including objects. Just make sure to provide an array of boolean values indicating whether to include each object in the filtered array.
  </Accordion>
</AccordionGroup>

## See Also

* [Array Block](/block-reference/data/array)
* [Compare Block](/block-reference/logic/compare)
* [Number Block](/block-reference/data/number)
* [Extract Object Path Block](/block-reference/modifiers/extract-object-path)
* [Evaluate Block](/block-reference/advanced/code)
* [Coalesce Block](/block-reference/logic/coalesce)
* [Join Block](/block-reference/modifiers/join)
