Minify HTML

Convert multi line HTML to runnable inline HTML code

Tags: compress code html minify code

Introduction

This is an online minifier tool which helps to minify/compress HTML code.

How to use this tool?

You can input/paste your HTML code directly into the editor, then click the minify button to minify the code.

After minifying, you can download, save or share the result. It will create a short link for you to share with others. You can also sign-in using Google/GitHub to save minifyed result into your account.

What is HTML?

HTML stands for Hypertext Markup Language. It allows the user to create and structure sections, paragraphs, headings, links, and blockquotes for web pages and applications.

HTML is not a programming language, meaning it doesn’t have the ability to create dynamic functionality. Instead, it makes it possible to organize and format documents, similarly to Microsoft Word.

Learn more

HTML Syntax

      
<html
<!doctype html>
<html lang="en">
  <head>
    <title>Hello World!</title>
  </head>
  <body>
    <div id="content">
      <h1 class="title">Hello World!</h1>
    </div>
  </body>
</html>
      
    

What is Minification?

Minification is the process of minimizing code and markup in your web pages and script files. It’s one of the main methods used to reduce load times and bandwidth usage on websites. Minification dramatically improves site speed and accessibility, directly translating into a better user experience. It’s also beneficial to users accessing your website through a limited data plan and who would like to save on their bandwidth usage while surfing the web.

Why minify HTML?

When creating HTML developers tend to use spacing, comments and well-named variables to make code and markup readable for themselves. It also helps others who might later work on the assets. While this is a plus in the development phase, it becomes a negative when it comes to serving your pages. Web servers and browsers can parse file content without comments and well-structured code, both of which create additional network traffic without providing any functional benefit.

To minify HTML files, comments and extra spaces need to be removed, as well as crunch variable names so as to minimize code and reduce file size. The minified file version provides the same functionality while reducing the bandwidth of network requests.

Examples

Before minified

      
<html
    style="color: green">
    <!-- this is a comment -->
    <head>
        <title>Mixed HTML Example</title>
        <style>
            h1 {
                font-family: comic sans;
                color: #f0f;
            }
            div {
                background: yellow !important;
            }
            body {
                max-width: 50em;
                margin: 1em 2em 1em 5em;
            }
        </style>
    </head>
    <body>
        <h1>Mixed HTML Example</h1>
        <script>
            function jsFunc(arg1, arg2) {
                if (arg1 && arg2)
                    document.body.innerHTML = "achoo";

            }
        </script>
    </body>
</html>
      
    

After minified

      
<html style="color: green"> <head><title>Mixed HTML Example</title><style>h1{font-family:comic sans;color:#f0f;}div{background:yellow !important;}body{max-width:50em;margin:1em 2em 1em 5em;}</style></head><body><h1>Mixed HTML Example</h1><script>function jsFunc(arg1,arg2){if(arg1&&arg2)document.body.innerHTML="achoo";}</script></body></html>