How to delete useless vertex groups from deleted bones?

Hello, someone help!
I made a rig and then remade it couple of times, and now I have tons of useless vertex groups in mesh from deleted bones that assigned to nothing. Is there a way to clean it, or should I check every bone and delete like 50 vertex group positions manually?

Maybe should help this: Delete orphans

Nice feature, but it doesn’t have bones or vertex groups!

I wrote a script that delete all blank vertex groups (if they have no vertices assigned), could it help? But if you need to delete vertex groups that have vertices assigned, but are not linked to any bones, this won’t work unfortunately.

Is there a request feature or something in

But if I have a bit of time off, i’ll work on a script, should not take too long.

Thank you very much. I’ll make a request anyway!

Here you go, copy-paste this in the Blender text editor, select the mesh object (must have an armature modifier), then “Run Script” or Alt-P to execute.

import bpy

def delete_nodeform_vgroups():
    arm = None
    arm = bpy.context.active_object.find_armature()
    if arm == None:
        print("No armature modifier found, add one")
    bones_list = [ for b in if b.use_deform]
    obj = bpy.context.active_object
    if len(obj.vertex_groups) == 0:
        print("No vertex groups found")
        for vgroup in obj.vertex_groups:
            if not in bones_list:
                print("Non deformable vertex group found:",


:thinking:thank you very much…
Is it hard to learn how to code and do plugins?

Be aware that if you have some other Vgroups used for other modifiers or other, if you run the script above by @lucky, they will be deleted as well.