This question already has an answer here:

I want to make a command block to make sure that anything that spawns in a village, dies, except players and villagers. Please help me.

marked as duplicate by Nelson, Lore Friendly, Schism, greg-449, Joachim Jul 10 at 7:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Since 1.13 you can use multiple of the same argument in one selector:

/kill @e[type=!player,type=!villager]

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