---
title: "Headless JavaScript PDF redaction library | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/web/redaction/headless/"
md_url: "https://www.nutrient.io/guides/web/redaction/headless.md"
last_updated: "2026-06-05T20:16:40.342Z"
description: "Run redaction workflows without UI using a production-safe sequence: mark/search, apply permanently, and export only after apply succeeds."
---

# Headless redaction

It’s possible to apply redaction operations without the need to present any user interface (UI) to the user.

Do not allow final export before `applyRedactions()` succeeds when compliance/sanitization is required.

## Standalone

In [Standalone mode](https://www.nutrient.io/guides/web/about/operational-modes.md) of Nutrient Web SDK, you can perform the operation using JavaScript in the browser by setting the `headless` option as `true` when loading the JavaScript library. This indicates you don’t want a UI:

```js

NutrientViewer.load({
    //...
    headless: true
}).then((instance) => {
    // Apply your operations.
}).catch((error) => {
    console.error("Failed to load viewer:", error.message);
});

```

Once the SDK is loaded, you can apply any of our operations as normal.

## Server-backed

When using the Server-backed [operational mode](https://www.nutrient.io/guides/web/about/operational-modes.md), a variety of operations are available server-side. Refer to the [Document Engine documentation](https://www.nutrient.io/guides/document-engine.md) for additional information.




## Complete headless example

Redact all Social Security numbers without showing the UI.

For export behavior recommendations (`exportPDF()` vs. `exportPDF({ flatten: true })`) and finalization sequencing, refer to the [production-safe redaction workflow](https://www.nutrient.io/guides/web/redaction/production-safe-workflow.md) guide.

```js

NutrientViewer.load({
  document: "document.pdf",
  headless: true
}).then(async (instance) => {
    // Search and create redaction annotations.
    const ids = await instance.createRedactionsBySearch(
      NutrientViewer.SearchPattern.SOCIAL_SECURITY_NUMBER,
      { searchType: NutrientViewer.SearchType.PRESET }
    );

    if (ids.length > 0) {
      console.log(`Found ${ids.length} SSNs to redact`);
      await instance.applyRedactions();
      const pdf = await instance.exportPDF();
      // Save or send the redacted PDF.
    } else {
      console.log("No SSNs found in document");
    }
  }).catch((error) => {
    console.error("Redaction failed:", error.message);
  });

```
---

## Related pages

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

