---
title: "Search & redact PDF using JavaScript | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/web/redaction/search-and-redact/"
md_url: "https://www.nutrient.io/guides/web/redaction/search-and-redact.md"
last_updated: "2026-06-08T09:14:14.473Z"
description: "It’s possible to use Nutrient Web SDK to automatically create redaction annotations based on specific search criteria. This could be a text term."
---

# Search and redact PDFs using JavaScript

It’s possible to use Nutrient Web SDK to automatically create redaction annotations based on specific search criteria. This could be a text term, a custom regular expression, or one of the built-in patterns Nutrient Web SDK ships with.

[Try for free](https://www.nutrient.io/sdk/web/getting-started.md)

[Launch demo](https://www.nutrient.io/demo/redaction)

[`NutrientViewer.Instance#createRedactionsBySearch()`](https://www.nutrient.io/api/web/NutrientViewer.Instance.html#createRedactionsBySearch) allows you to specify the search criteria, along with specifying a custom redaction [annotation preset](https://www.nutrient.io/guides/web/customizing-the-interface/using-annotation-presets.md) to be used when creating redactions based on search results. By default, content inside annotations will be also be included in the search results, but this can be adjusted with the `searchInAnnotations` Boolean property as part of the `options` argument.

Here’s an example showing how to redact all occurrences of Nutrient in a document, without including annotations in the results:

```js

const annotationIds = await instance.createRedactionsBySearch("PSPDFKit", {
  searchInAnnotations: false
});

```

You can also use one of our [built-in patterns](https://www.nutrient.io/guides/web/redaction/preset-patterns.md) to quickly identify sensitive information that needs to be redacted, or use your own [custom regex patterns](https://www.nutrient.io/guides/web/redaction/regex-patterns.md).

Refer to our API documentation of [`NutrientViewer.Instance#createRedactionsBySearch()`](https://www.nutrient.io/api/web/NutrientViewer.Instance.html#createRedactionsBySearch) to learn more.
---

## Related pages

- [JavaScript PDF redaction library](/guides/web/redaction.md)
- [PDF redaction techniques for your documents](/guides/web/redaction/introduction-to-redaction.md)
- [Production-safe redaction workflow](/guides/web/redaction/production-safe-workflow.md)
- [Redact PDFs using JavaScript tools](/guides/web/redaction/built-in-ui.md)
- [Programmatically redact PDFs using JavaScript](/guides/web/redaction/programmatically.md)
- [Redact PDFs using regex](/guides/web/redaction/regex-patterns.md)
- [Headless redaction](/guides/web/redaction/headless.md)
- [Automate document redaction with predefined patterns](/guides/web/redaction/preset-patterns.md)

