Converting nodes into python script

For various purposes I might want the code that generates the structure of a node group, I want to convert the code into a script that when run can regenerate the nodes I made in shader or geometry nodes.

I could find various things on this, but nothing worked, apparently the Node wrangler addon should have a convert to python feature I cannot find.

I think these two products that seem to do what you want:

And don’t forget:

1 Like

unfortunately this one is outdated. it doesn’t work for blender 3.6. https://github.com/BrendanParmer/NodeToPython/issues/94

Unless it is a prerequisite for you to generate node trees using the API, it might to helpful to consider packaging the necessary node trees into node groups, save them in a blend file, and use it as a library to append things off of from your script.

Not that it isn’t possible, but dealing with nodes through the API is not entirely fun to do.