JavaScript Minifier
Minifies JavaScript with Terser and reports the size saving.
Beautify minified or badly indented JavaScript so you can read and debug it. Choose the indent and brace style, and keep or collapse your blank lines.
.js file.The code is split into tokens (keywords, names, strings, regex literals, operators) by js-beautify, then written out again with new whitespace.
{ at the end of the line, Next line moves it down (Allman style), and End expand puts else and catch on a new line after }.Input:
function add(a,b){if(!b){return a}return a+b}const total=[1,2,3].reduce((s,n)=>add(s,n),0);Formatted with 2 spaces and braces on the same line:
function add(a, b) {
if (!b) {
return a
}
return a + b
}
const total = [1, 2, 3].reduce((s, n) => add(s, n), 0);
a and b stay short, and removed comments can't come back.It restores line breaks and indentation, so minified code becomes readable. Original variable names and comments can't be recovered, because minification removes them.
No. Only whitespace changes, and the formatter treats strings, regex literals, and template literals as single tokens. Code that ran before runs the same afterwards.
Most JavaScript style guides, including Airbnb, Google, and StandardJS, keep the opening brace on the same line.
No. Formatting runs in your browser.
Often used together with the JavaScript Formatter.
Minifies JavaScript with Terser and reports the size saving.
Beautifies or minifies JSON.
Beautifies HTML with consistent indentation, including inline CSS and JavaScript.