Be careful that you have some idea of what is happening or you will corrupt the integrity of your documents. A fully minified code sample removes all comments and all white space characters not necessary for syntactical purposes.
In other words this example of HTML:
in this paragraph.</p>
When fully minified becomes:
In that case the corruption to the content is obvious as all the words are colliding into each other. What is not obvious is the space buffering content and tags and the spaces between tags not adjacent to other content. All white space characters outside of tags in a HTML document are text nodes in the DOM and removing DOM nodes without careful consideration is possibly harmful.
Here is one that I wrote which may be helpful to you as it minifies markup tags in a way that is fully recursive to a beautified state using an automated pretty-print application.