---
title: "Remove PDF annotations using JavaScript | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/web/annotations/create-edit-and-remove/remove/"
md_url: "https://www.nutrient.io/guides/web/annotations/create-edit-and-remove/remove.md"
last_updated: "2026-06-08T09:14:14.457Z"
description: "In addition to an API for editing annotations, we also provide an API for removing those annotations directly on the client."
---

# Remove PDF annotations using JavaScript

In addition to an API for editing annotations, we also provide an API for removing those annotations directly on the client. Following the optimistic UI approach, the changes will be instantly visible in the UI, but they aren’t persisted until the annotations are saved.

To remove annotations, use [`Instance#delete`]. This API requires the annotation IDs only. Try this example in the [Playground](https://www.nutrient.io/demo/sandbox?p=eyJ2IjoxLCJjc3MiOiIvKiBBZGQgeW91ciBDU1MgaGVyZSAqL1xuIiwianMiOiJjb25zb2xlLmxvZyhcIkRlbW9uc3RyYXRpbmcgYW5ub3RhdGlvbiBkZWxldGlvbi4uLlwiKTtcblxuTnV0cmllbnRWaWV3ZXIubG9hZCh7XG4gIC4uLmJhc2VPcHRpb25zLFxufSkudGhlbihhc3luYyAoaW5zdGFuY2UpID0%252BIHtcbiAgY29uc29sZS5sb2coXCJOdXRyaWVudCBsb2FkZWQhXCIpO1xuXG4gIGNvbnN0IGFubm90YXRpb24gPSBuZXcgTnV0cmllbnRWaWV3ZXIuQW5ub3RhdGlvbnMuTm90ZUFubm90YXRpb24oe1xuICAgIHBhZ2VJbmRleDogMCxcbiAgICBib3VuZGluZ0JveDogbmV3IE51dHJpZW50Vmlld2VyLkdlb21ldHJ5LlJlY3Qoe1xuICAgICAgbGVmdDogMTAwLFxuICAgICAgdG9wOiAxMDAsXG4gICAgICB3aWR0aDogMzAsXG4gICAgICBoZWlnaHQ6IDMwLFxuICAgIH0pLFxuICAgIHRleHQ6IHtcbiAgICAgIGZvcm1hdDogXCJwbGFpblwiLFxuICAgICAgdmFsdWU6IFwiVGhpcyBub3RlIHdpbGwgYmUgZGVsZXRlZCBpbiAzIHNlY29uZHNcIixcbiAgICB9LFxuICB9KTtcbl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instance) => {
    try {
      const annotations = await instance.getAnnotations(0);
      console.log(`Found ${annotations.size} annotations`);

      if (annotations.size === 0) {
        console.warn("No annotations found on page 0");
        return;
      }

      const annotation = annotations.get(0);
      await instance.delete(annotation);
      console.log("Annotation deleted.");
    } catch (error) {
      console.error("Failed to delete annotation:", error.message);
    }
  }).catch((error) => {
    console.error("Failed to load NutrientViewer:", error.message);
  });

```

Once annotations have been edited, they’ll need to be persisted. This is done by saving them. [Save them to external storage](https://www.nutrient.io/guides/web/annotations/save/to-external-storage.md) or [embed them into the document](https://www.nutrient.io/guides/web/annotations/save/embed-into-pdf.md). They can also be exported to [XFDF](https://www.nutrient.io/guides/web/importing-exporting/xfdf-support.md) or [Instant JSON](https://www.nutrient.io/guides/web/importing-exporting/instant-json.md). If you’re using Web SDK with Document Engine, they can be [synced with the backend](https://www.nutrient.io/guides/web/annotations/import-and-export/server-backed.md).
---

## Related pages

- [Add image annotations to PDFs using JavaScript](/guides/web/annotations/create-edit-and-remove/add-image.md)
- [Annotation flags](/guides/web/annotations/annotation-flags.md)
- [Defining the author of an annotation](/guides/web/annotations/annotation-author-name.md)
- [Cut, copy, paste, and duplicate annotations in PDF using JavaScript](/guides/web/annotations/create-edit-and-remove/cut-copy-duplicate.md)
- [Create PDF annotations using JavaScript](/guides/web/annotations/create-edit-and-remove/create.md)
- [Detect changes in annotations](/guides/web/annotations/detecting-if-annotations-have-changed.md)
- [Edit PDF annotations using JavaScript](/guides/web/annotations/create-edit-and-remove/edit.md)
- [Select PDF annotations using JavaScript](/guides/web/annotations/create-edit-and-remove/multiple-selection.md)
- [Undo and redo annotations](/guides/web/annotations/create-edit-and-remove/undo-redo.md)
- [Rich text in PDF annotations using JavaScript](/guides/web/annotations/create-edit-and-remove/rich-text.md)
- [Customizing annotation permissions](/guides/web/annotations/create-edit-and-remove/permissions.md)

