Using the JavaScript Minifier
This page removes JavaScript comments and extra spaces outside strings. The sample is function a() { return 1; } written on several lines, with a line break after the opening brace and the return indented. It becomes function a(){ return 1;}. Note the space after the opening brace. That space is the collapsed line break between the brace and return. There is no space before the closing brace. The page does not run the script. It does not call the function, and it does not tell you what the return would do in a browser.
The headline is Minified JavaScript. The text under the headline is the minified script, and that text is what you copy. A line counts the characters in the result. The field accepts from 1 to 20000 characters. A blank field, or a longer paste, is rejected. If comments and spaces are all that remain, the page says to enter JavaScript that still has code after comments are removed. The sample still has code, so it produces function a(){ return 1;}.
Line comments and block comments outside quotes are removed. Text inside quotes stays, including spaces inside a string. This is not a full parser, so a comment mark inside a regular expression can be left as typed. Reset returns the field to the several-line sample. The previous result stays on screen until you minify again. Use the space after the opening brace as the check that the sample was collapsed rather than executed.
Read function a(){ return 1;} as a sequence of pieces. The word function, a space, the name a, the parentheses, the opening brace, one space, the word return, a space, the digit 1, the semicolon, and the closing brace. The space that matters for the sample is the one immediately after the brace. Removing that space produces a different string from the one this page returns for the several-line input. Keeping a space before the closing brace also produces a different string. The page does not run the script, so neither space is there because a function call needed it. The spaces are what remain after comments outside quotes are removed and extra spaces outside quotes are collapsed. Quote characters, when you add them, freeze the spaces inside them. A comment mark inside a regular expression can be left as typed because this is not a full parser, which is a separate limit from the sample's brace space.
What the Brace Space Means
The sample starts as a function split across lines. The name is a. The body returns the number 1. After minifying, the text is function a(){ return 1;}. The space after the opening brace is required reading. It is the single space that replaced the line break and the indent before return. The characters { and } remove a space that would have sat immediately before them, so the space that follows the opening brace remains and a space before the closing brace does not. The headline is Minified JavaScript. The page does not run the script, so the 1 is still source text. It is not a value the page computed by calling a.
Quotes are the region the space rules do not enter. A string such as "b c" keeps the space between b and c. A line comment that starts with two slashes outside quotes is removed through the end of that line. A block comment outside quotes is removed through its close. If the paste is only a comment, nothing remains and the page rejects it. The sample is not only a comment. It still contains function a(){ return 1;} after the line breaks are collapsed.
How the Sample Is Collapsed
The page reads the paste one character at a time. Inside a single quote, a double quote, or a backtick, characters are copied, including spaces, until the quote ends. Outside quotes, a line comment and a block comment are skipped. A run of whitespace becomes one space, and that space is kept only when something other than space already sits before it. The marks { } ( ) ; , and the arithmetic marks drop a space that sits against them on the left. Applied to the sample, the line break after { becomes one space, return stays, the space before 1 stays, and the closing brace sits against the semicolon. The result is function a(){ return 1;}. The page does not run the script.
A style rule collapses a different grammar. 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 produce function a(){ return 1;}. Use it when the paste is CSS. Use this page when the paste is JavaScript and you need the space after the opening brace to remain in the sample.
What the Page Does Not Run
The page does not run the script. function a(){ return 1;} is source. The page does not call a, does not evaluate the return, and does not report that the number 1 is a result of execution. The headline Minified JavaScript names the cleanup. The character count is the length of the source that remains. A comment removed from the paste is gone from that source. A string kept in the paste is still a string, spaces included.
This is not a full parser. A comment mark inside a regular expression can be left as typed. The page does not build a syntax tree, and it does not promise to understand every slash the way a JavaScript parser would. Quotes are the construct it does treat as a region: while a quote is open, comment marks are ordinary characters and stay. Outside quotes, two slashes start a line comment and a slash followed by a star starts a block comment. The sample has neither, so the only change is the collapsed space, leaving the space after the opening brace.
The Sample and a Quoted Space
Paste function a() { return 1; } on several lines. Confirm the result is function a(){ return 1;} and that there is a space after the opening brace and no space before the closing brace. Confirm the headline is Minified JavaScript. Change the returned value to a string with a space inside the quotes. Confirm that space remains while the line breaks outside the quotes still collapse. Add a line comment outside the quotes and confirm the comment is gone and the function text remains. Paste only a comment and confirm the page asks for JavaScript that still has code after comments are removed. The page does not run the script on any of these tries.
An HTML fragment loses spaces under a different rule. The HTML Minifier turns a p element with Hi on its own line into <p>Hi</p>. The headline is Minified HTML. Comments are removed. A pre block stays as typed. A script is rejected. That page does not return function a(){ return 1;}. Use it when you want shorter HTML. Use this page when you want the JavaScript sample collapsed, with the space after the opening brace kept.
Quotes, Comments, and the Cap
The paste must be from 1 to 20000 characters. Comments outside quotes are removed. Spaces outside quotes collapse, with the special marks stripping a space on their left. Text inside single quotes, double quotes, and backticks stays as typed, including a comment mark that sits inside the quotes. A comment mark inside a regular expression can be left as typed because this is not a full parser. The sample does not rely on that case. The sample relies on the space after the opening brace in function a(){ return 1;}.
The page does not run the script, so a function that would throw if called is still only text to minify. The page does not fetch a file named by a string in the script. If the field is blank or too long, nothing is minified. If the field is only comments, the rejection is the message about code remaining after comments are removed. That message is different from the length message. The sample hits neither rejection.
Mistakes That Erase the Brace Space
The usual miss is to delete every space and write function a(){return 1;}. The sample result has a space after the opening brace: function a(){ return 1;}. Another miss is to expect the page to run the function and show 1 as a calculated answer. The page does not run the script. The 1 is still in the source. Another miss is to expect a space inside quotes to disappear. That space stays. Another miss is to expect a full parse that understands every regular expression. A comment mark inside a regular expression can be left as typed because this is not a full parser. Another miss is to copy the headline Minified JavaScript instead of the text under it.
JSON space is removed only after a parse. The JSON Minifier turns {"a": 1} into {"a":1}. The compact value is 7 characters. Invalid JSON is rejected rather than trimmed by hand. That page does not produce function a(){ return 1;}, and it does not leave a space after a brace in a JavaScript function. Use it when the paste is JSON. Use this page when the paste is the several-line function.
Keeping the Minified Function
Copy function a(){ return 1;} and keep the several-line original beside it. Confirm the space after the opening brace before you replace any file you care about. Confirm the semicolon still sits before the closing brace. If you added a string, confirm every space inside the quotes survived and every line comment outside the quotes did not. The page does not run the script, so the copy is not a log of a call. It is the source after comments and extra spaces were removed. A second run of the sample returns the same characters, including that one space after the brace. If you compare character counts, count the result you copied, not the several-line original. The original is longer because of the line breaks and the indent. The result is shorter, and it still contains the space after the opening brace. A count that matches the original means you copied the input. A count that omits the space after the brace means the copy is not this page's output for the sample. The headline Minified JavaScript is not part of that count. The count belongs to the text under the headline.
Reset restores the several-line function in the field. Minify again if you want to see the collapse once more. A rejection that mentions comments means the paste had no code left. A rejection that mentions 20000 characters means the paste was too long or empty. Neither rejection is a minified function. Do not save the rejection text as the script.
Minifying the Sample Again
Enter the several-line function a() { return 1; }. Confirm function a(){ return 1;} and look at the space after the opening brace. Run it again and confirm the same text. Put a space inside a quoted string and confirm the space stays. Put a line comment outside the quotes and confirm the comment is removed. Submit a comment with no code and confirm the rejection. The page does not run the script during these checks. The headline stays Minified JavaScript on every successful run.
Laying the same kind of braces out for reading is a different page. The JSON Prettifier formats one JSON value with line breaks and four-space indentation. {"a":1} becomes a formatted object whose key a is set to the number 1. The headline is Formatted JSON. Invalid JSON is rejected with Enter valid JSON. That page does not fetch JSON, and it does not return function a(){ return 1;}. Use it when you want indented JSON. Use this page when you want the JavaScript sample shortened.
What the Minified Line Shows
The minified line shows that comments outside quotes are gone and that extra spaces outside quotes collapsed, while the sample kept one space after the opening brace. function a(){ return 1;} is that line. The headline Minified JavaScript names it. The character count measures it. A string space that you saw survive was inside quotes. A comment you saw vanish was outside quotes. A comment mark inside a regular expression can be left as typed because this is not a full parser. The page does not run the script in any of those cases.
You can say the several-line sample becomes function a(){ return 1;}. You can say there is a space after the opening brace. You can say the page does not run the script. You cannot say every slash was interpreted as a parser would interpret it. You cannot say a space inside quotes was removed. You cannot say a comment-only paste came back as an empty success. That paste is rejected. Read the result aloud as function, a, parentheses, brace, space, return, space, 1, semicolon, brace, so the space after the opening brace is heard and not skipped. That reading matches the headline Minified JavaScript for this sample.
Checking the Brace Space
Start with the several-line sample. The result should be function a(){ return 1;}, with a space after { and the headline Minified JavaScript. Then keep a space inside quotes and confirm it survives. Then remove a line comment and confirm the function remains. Then submit only a comment and confirm the rejection. The page does not run the script, so the check is the characters of the result, not a console. If the space after the opening brace is missing, the sample was not collapsed the way this page collapses it.
A token's header and payload are a different decode. The JWT Decoder decodes the header and the payload of a JSON Web Token. The page does not check the signature, so a decoded payload is not proof that the token is genuine. The signature line reads Not checked. That page does not minify function a(){ return 1;}. Use it when you want the decoded parts of a token. Use this page when you want the JavaScript sample shortened without running it.