# How do I delete a shader node (From Script)?

I am writing an addon and I need to delete an image texture node from the active material. I know that the python for deleting the node from the editor is bpy.ops.node.delete(), but I don't know how to make this work from the script. I might sound dumb asking this, but I am a beginner to writing addons.

Thanks in advance!

## 1 Answer

You can do something like this:

import bpy

#Get the material you want (replace the name below)
mat = bpy.data.materials['Material']

#Get the node in its node tree (replace the name below)
node_to_delete =  mat.node_tree.nodes['Principled BSDF']

#Remove it
mat.node_tree.nodes.remove( node_to_delete )