> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/help/llms.txt)

# filter

In the Mapbox Style Specification, a **filter** is a property at the [layer level](https://docs.mapbox.com/style-spec/reference/layers/#filter) that determines which features should be rendered in a style [layer](https://docs.mapbox.com/help/glossary/layer/). Filters are written as [expressions](https://docs.mapbox.com/help/glossary/expression/), which give you fine-grained control over which features to include: the style layer only displays the features that match the filter condition that you define. Filters are called **predicates** in iOS and macOS.

This code from the [Filter symbols by text input](https://docs.mapbox.com/mapbox-gl-js/example/filter-markers-by-input/) example includes a filter expression that singles out all features where `"icon"` is equal to `symbol` (a variable that is set to the selected feature's icon property):

```js
map.addLayer({
  id: layerID,
  type: 'symbol',
  source: 'places',
  layout: {
    'icon-image': symbol + '-15',
    'icon-allow-overlap': true
  },
  filter: ['==', 'icon', symbol]
});
```

Older versions of the Mapbox Style Specification used a [property-based filter syntax](https://docs.mapbox.com/style-spec/reference/other/#other-filter). While that older syntax still works, it will ultimately be deprecated and replaced by filter expressions.

**Related resources:**

-   [Filter documentation](https://docs.mapbox.com/style-spec/reference/layers/#filter)
-   [Expression documentation](https://docs.mapbox.com/style-spec/reference/expressions/)
-   Example: [Highlight features containing similar data](https://docs.mapbox.com/mapbox-gl-js/example/query-similar-features/)
-   Example: [Filter symbols by text input](https://docs.mapbox.com/mapbox-gl-js/example/filter-markers-by-input/)
-   Troubleshooting: [Optimize expressions](https://docs.mapbox.com/help/troubleshooting/mapbox-gl-js-performance/#optimize-expressions)