Using the HTML Minifier
This page removes extra spaces from an HTML fragment. The sample is a p element with Hi on its own line, indented between the opening tag and the closing tag. That fragment becomes <p>Hi</p>. The line break and the indent disappear. Hi sits against the tags. The headline is Minified HTML. The text under the headline is the minified fragment, and that text is what you copy. A line counts the characters in the result. The page does not fetch a page.
Comments are removed. A comment is the stretch from the comment opening to the comment close, and that stretch is deleted before the remaining spaces are collapsed. A pre block stays as typed. Spaces and line breaks inside pre remain after the rest of the fragment is tightened. A script is rejected. A document type is rejected with the same message: remove the document type and any script before minifying. The field accepts from 1 to 20000 characters.
A run of spaces in ordinary text becomes one space. Spaces that sit against a tag are removed, which is why the sample does not keep a space before Hi or after Hi. Reset returns the field to the sample p element with Hi on its own line. The previous minified text stays on screen until you minify again. <p>Hi</p> is the check that the headline Minified HTML matches this cleanup.
Count the sample result when you want a second check beside the character line. <p>Hi</p> is nine characters: the opening tag, the letters H and i, and the closing tag. There is no line break in those nine characters and no space before Hi. If your copy of the result is longer, a space or a break from the original paste is still present and the collapse did not match this page. If your copy is shorter, a letter or a bracket was dropped. The headline Minified HTML does not include those nine characters in the heading itself. They live in the text under the headline. Comments never add to that count, because comments are removed before the count is taken. A pre block does add its characters, including the spaces you typed inside it, because a pre block stays as typed. The page does not fetch a page to obtain either the nine-character sample or a longer fragment.
What the Sample Collapses
The sample starts with an opening p tag, then a line break, then spaces, then Hi, then a line break, then the closing p tag. After minifying, those breaks and spaces are gone and the text is <p>Hi</p>. The letters H and i stay. The tags stay. The headline is Minified HTML, so the heading is the name of the result, not the fragment itself. Copy the text under the headline when you want <p>Hi</p>. The character count is the length of that text. The page does not fetch a page, and it does not request anything that an address in the fragment might name.
Comments are removed even when they sit beside the sample. A comment after the p element disappears, and <p>Hi</p> remains if that was the rest of the fragment. A pre block stays as typed, so a pre element that contains a line break and two spaces still contains that line break and those two spaces. Ordinary text does not get that exception. Two spaces between words outside pre become one space. A script is rejected before either of those rules runs.
How Spaces Are Removed
The page checks the length, then rejects a document type or a script. Comments are removed next. The fragment is then split so each pre block is set aside as typed. Outside those blocks, a run of whitespace becomes one space, spaces after a tag are removed, and spaces before a tag are removed. The ends of the result are trimmed. The sample has no pre block and no comment, so the line breaks around Hi collapse and the result is <p>Hi</p>. The headline is Minified HTML. The page does not fetch a page during that pass.
A style rule loses spaces in a different way. The CSS Minifier removes CSS comments and extra spaces. A rule a { color: red; } becomes a{color:red;}. That page does not check that the CSS is valid, and it does not turn a p element with Hi on its own line into <p>Hi</p>. Use it when the paste is CSS. Use this page when the paste is HTML and you want the sample to become <p>Hi</p>, with comments removed and a pre block left as typed.
What Minifying Leaves in Place
Minifying removes spaces, line breaks outside pre, and comments. It does not rewrite tag names, and it does not drop Hi. <p>Hi</p> still has a p element and the word Hi. A pre block stays as typed, which means the minifier is not a general deletion of every space in the field. The exception is deliberate. Preformatted text is the region where the spaces are part of what you meant to keep. Comments are the region that is deleted even though they are not only spaces.
A script is rejected rather than stripped into a shorter script. A document type is rejected rather than deleted and ignored. The message names both. The page does not fetch a page to find a replacement fragment. If the field is empty, or longer than 20000 characters, the page asks for 1 to 20000 characters and does not return <p>Hi</p>. If spaces and comments are all that remain, the page says to enter HTML that still has a character after spaces are removed.
The Sample, a Comment, and Pre
Paste the p element with Hi on its own line. Confirm the result is <p>Hi</p> and the headline is Minified HTML. Add a comment beside it and confirm the comment is gone while <p>Hi</p> remains. Paste a pre block that contains a line break and extra spaces and confirm that block stays as typed. Paste Hi with two spaces between extra letters outside pre and confirm the run of spaces becomes one space. Paste a script and confirm the rejection. Paste a document type and confirm the same rejection. The page does not fetch a page on any of these tries.
A script's own spaces are a different cleanup, and only after the script is accepted by a different page. The JavaScript Minifier removes comments and extra spaces outside strings. function a() { return 1; } on several lines becomes function a(){ return 1;}. Note the space after the opening brace. That page does not run the script. A comment mark inside a regular expression can be left as typed because that page is not a full parser. It does not produce <p>Hi</p>. Use it for JavaScript. Use this page for the HTML sample.
Comments, Pre, and the Cap
Comments are removed from the whole fragment before pre blocks are copied through. A pre block stays as typed after that removal, so the spaces that were not part of a comment remain inside pre. Outside pre, whitespace collapses and spaces touching tags are removed. The sample becomes <p>Hi</p> by that outside rule. The headline is Minified HTML. The page does not fetch a page, and it does not treat a URL in an attribute as something to download and minify.
The length cap is 20000 characters on the paste, counted before minifying. A script is rejected. A document type is rejected. Those rejections happen even when the rest of the fragment looks like the sample. The page will not delete the script and return the p element. Remove the script yourself, then minify. If the only characters left are spaces, the result is rejected because nothing remains to show under the headline.
Mistakes That Keep the Line Break
The usual miss is to expect Hi to stay on its own line. The sample becomes <p>Hi</p>. Another miss is to expect a comment to survive because it sits inside the fragment you want to keep. Comments are removed. Another miss is to expect a pre block to collapse like the p element. A pre block stays as typed. Another miss is to leave a script in the paste. A script is rejected. Another miss is to think the page loaded a document because the result still looks like HTML. The page does not fetch a page. Another miss is to copy the headline Minified HTML and think you copied <p>Hi</p>. The fragment is the text under the headline.
Turning tags into Markdown is a different reading. The HTML to Markdown tool converts a fragment. <p>Hello</p> becomes Hello. <h1>Hi</h1> becomes # Hi. A script and a document type are rejected. The supported tags are h1, h2, h3, p, strong, em, code, a, ul, ol, and li. That page does not fetch a page, and it does not return <p>Hi</p> as the minified sample. Use it when you want Markdown. Use this page when you want the spaces removed and the tags kept.
Keeping the Minified Fragment
Copy <p>Hi</p> and keep the original p element, with Hi on its own line, beside it until you have seen the line break disappear. If the paste also had a comment, confirm the comment is absent from the copy. If the paste had a pre block, confirm that block still matches the original characters. Write the headline Minified HTML in your note only as the name of the result. The fragment you reuse is <p>Hi</p>, or whatever the text under the headline shows for your own paste. The page does not fetch a page, so the copy is not a response from a host. For a fragment longer than the sample, compare the first tag and the last tag with the original, then search the copy for a comment opening. A comment opening in the copy means the removal did not match this page. A line break inside a pre block should still be there. A line break that used to sit between ordinary tags should be gone. Those two observations, taken together, are the practical test that comments were removed, the pre block stayed as typed, and the sample rule for Hi still holds on the surrounding markup.
Reset restores the sample in the field. Minify again and confirm <p>Hi</p> returns. A longer fragment should be checked at the first tag and the last tag, because trimming applies to the ends of the whole result. A script that was rejected never produced a fragment to keep. Remove it, minify the remainder, and store that remainder. Do not store the rejection message as if it were HTML.
Minifying the Sample Again
Enter the p element with Hi on its own line. Confirm <p>Hi</p> and the headline Minified HTML. Run it again and confirm the same text. Add a comment and confirm the comment is removed. Add a pre block with internal spaces and confirm those spaces stay. Enter a script and confirm the rejection. Enter a document type and confirm the rejection. Enter only spaces and confirm the page asks for HTML that still has a character after spaces are removed. The page does not fetch a page while you repeat the sample.
The reverse direction, from Markdown back to tags, is a different page. The Markdown to HTML tool converts a small Markdown subset to HTML. A line # Hi and a following paragraph Hello become an h1 and a paragraph. Raw HTML in that source is escaped. The subset is headings, paragraphs, bold, italic, code, and dash lists. That page does not collapse the sample p element into <p>Hi</p>. Use it when you are starting from # Hi. Use this page when you are starting from HTML and want the extra spaces gone.
What Minified HTML Means
Minified HTML means the comments are gone, a pre block stays as typed, and the other spaces have been collapsed so the sample p element with Hi on its own line is <p>Hi</p>. The headline is that name. The character count is the length of the text under it. A rejection means a script or a document type was present, the length was outside 1 to 20000 characters, or nothing remained after spaces were removed. The page does not fetch a page in the success case or in the rejection case.
You can say the sample becomes <p>Hi</p>. You can say comments are removed. You can say a pre block stays as typed. You can say a script is rejected. You cannot say the page opened a document and saved a shorter file on that host. You cannot say spaces inside pre were collapsed. You cannot say a comment was kept because it looked important. The comment rule does not read the words inside the comment. The headline Minified HTML is the name of a successful result. It is not a promise that every paste shrinks. A fragment that was already tight can come back the same length once comments are gone and spaces that were never there stay absent. The sample shrinks because Hi started on its own line. Measure the sample by reading <p>Hi</p>, then measure your own fragment by the same rules: comments gone, pre left as typed, other spaces collapsed, and no fetch of a page.
Checking the Sample Fragment
Start with the p element that has Hi on its own line. The result should be <p>Hi</p> and the headline should be Minified HTML. Then add a comment and confirm it disappears. Then minify a pre block and confirm the internal spacing survives. Then reject a script. Then reject a document type. The page does not fetch a page, so the check is immediate and local to the field. If the sample still has Hi on its own line in the result, the spaces were not collapsed. If a pre block lost its line break, the pre exception did not hold.
A JSON value loses a different kind of space. The JSON Minifier parses JSON and writes it without insignificant space. {"a": 1} becomes {"a":1}. The headline for that sample is a character count, and the compact value is 7 characters. Invalid JSON is rejected. That page does not turn the p element into <p>Hi</p>. Use it when the paste is JSON. Use this page when the paste is HTML.