HTML Question

Online or Offline tool to align html script into same line and remove extra-spaces?

Is there any online or offline tool to align HTML scripts into same line and remove extra-spaces for example:

Before:

<head>
<h1>This is my page.</h1>
</head>
<body>
<h4>Text example.</h4>
</body>


After:

<head><h1>This is my page.</h1></head><body><h4>Text example.</h4></body>


I want a tool because my scripts are too large to do this manually, if so it will take me some time to finish.

Answer