# Find empty layers and delete them

**URL:** <https://krita-artists.org/t/find-empty-layers-and-delete-them/74340>\
**Category:** Develop\
**Tags:** scripting-help\
**Created:** [September 18, 2023, 10:32am UTC](https://krita-artists.org/t/find-empty-layers-and-delete-them/74340 "2023-09-18T10:32:13Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![freyalupen](https://krita-artists.org/user_avatar/krita-artists.org/freyalupen/32/47913_2.png) [@freyalupen](https://krita-artists.org/u/freyalupen)\
**Post date:** [September 18, 2023, 4:35pm UTC](https://krita-artists.org/t/find-empty-layers-and-delete-them/74340/3 "2023-09-18T16:35:16Z")

</div>

This should work. Compared to the script in the linked thread, it checks exactBounds instead of extent.

```auto
from krita import *

doc = Krita.instance().activeDocument()
root = doc.rootNode()

allNodes = root.findChildNodes("", True)
for layer in allNodes:
    if layer.bounds().isEmpty():
        layer.remove()

```

---

_[View the full topic](https://krita-artists.org/t/find-empty-layers-and-delete-them/74340)._
