how to fix stray tags automatically



i am validating my wp theme. every thing looks fine. but the validator says that

there are some stray tags

and also that

there is a closing tag but there are open elements

i trying from few days to fix these tags but whenever i change
something add/remove some tags; theme’s visual design is disturbed(theme
file is fairly complex).
I am wondering if there is any tool to fix these tags automatically?
i have options to use following IDEs: Netbeans, Atom, sublime text2 and