2

Is it possible to delete all hidden layers in Illustrator at once and how would I do this?

1
  • 3
    I'm voting to close this question as off-topic because it's merely a yes or no question:
    – Scott
    Commented Jun 6, 2018 at 13:46

6 Answers 6

5

Here's a script to delete all layers.

#target illustrator
var myDoc=app.activeDocument;
var layerCount=myDoc.layers.length;
for (var ii = layerCount - 1; ii >= 0; ii--) {
    var currentLayer = myDoc.layers[ii];
    currentLayer.locked = false;
    if (currentLayer.visible == false){
        currentLayer.visible = true;
        currentLayer.remove();
        }
    }

Note that this will not work on any hidden layer that is locked or where the group is locked that it is inside.

To install the script, just copy the code into a notepad and save it as all files and with the filename delete_hidden_layers.jsx.

Then drop a copy of that into your scripts folder. It can be found under

C:\Program Files\Adobe\Adobe Illustrator [YOUR VERSION]\Presets\en_[YOUR LANGUAGE]\Scripts

OR

C:\Program Filesx86\Adobe\Adobe Illustrator[YOURVERSION]\Presets\en_[YOUR LANGUAGE]\Scripts

Interestingly enough Photoshop seems to have this feature built into its functionality.

enter image description here

1
  • This script looks like it will unlock all layers in the document, which may not be desirable. Why not move the unlocking inside the if block to make sure it’s only hidden layers? Commented Jun 9, 2018 at 14:41
3

To easily delete all your hidden layers:

  1. Deselect everything.
  2. Navigate to: 'Object' > 'Show All'. (This will both select and reveal all your hidden layers).
  3. Click: [Delete]

That's it!

2

No. The default installation of Illustrator provides no mechanism to delete layers other than manual deletion.

You may be able to use a third party script.

1

Here a script to download, similar to Ovaryraptor's, and tested as shown in this GIF:

hiddenlayers

Script:

#target Illustrator
var myDoc=app.activeDocument;
var layerCount=myDoc.layers.length;
for (var ii = layerCount - 1; ii >= 0; ii--) {
    var currentLayer = myDoc.layers[ii];
    currentLayer.locked = false;
    var subCount = currentLayer.layers.length;
    for (var ss =subCount -1; ss >= 0; ss--){
        var subLayer = currentLayer.layers[ss];
        subLayer.locked = false;
        if (subLayer.visible == false){
            subLayer.visible = true;
            subLayer.remove();
            }
        }
    if (currentLayer.visible == false){
        currentLayer.visible = true;
        currentLayer.remove();
        }
    }
1
  • Instead of adding a download link you should add the script itself to your answer. It's short enough and we don't have to worry about that link dying one day and invalidating your answer.
    – Luciano
    Commented Jun 10, 2018 at 10:36
0

In Illustrator CC 2019, unselect all layers, then go to the menu Object->Show All. Your hidden layers will appear and be selected. Press Delete.

1
  • This is the correct answer.
    – Stephen
    Commented Mar 11, 2022 at 16:51
0

Click the menu above layers and there is an option to 'Delete hidden layers' enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.