⚡ JavaScript Minifier & Beautifier
Minify, compress and beautify JavaScript code. Runs in your browser.
Last updated: November 8, 2026 · By the BoltQuickTools team
Stripping or restoring JavaScript whitespace
You want a quick way to shrink a small script for a page with no build step, or to reformat a minified file enough to read it. This page does both with a character-level scanner. It is not a full parser, and that shapes everything below, so read the semicolon warning before using its output in production.
The controls
- Paste code into Input JavaScript.
- Press Minify to remove comments and collapse whitespace, or Beautify to re-indent with two spaces.
- Read the result in Output JavaScript. The line below it shows original size, output size and, for Minify, the savings.
- Copy Output copies it, and Clear empties both boxes.
A small script, minified
// add two numbers
function add(a, b) {
/* no validation */
return a + b;
}
const label = "a // b";
console.log(add(2, 3), `sum: ${label}`);
Minify produces:
function add(a,b){return a+b;}const label="a // b";console.log(add(2,3),`sum: ${label}`);
The stats read Original: 146 chars (7 lines), Output: 91 chars (1 lines), Savings: 37.7%. The double slash inside the string survives, as does everything in the template literal.
What it keeps, and what it can still get wrong
A line break stays in the output wherever automatic semicolon insertion could depend on it, and a space stays between two identifier characters and between repeated plus or minus signs. The page does not parse the result, so "Minification complete" only means the scan finished. All of these came from running the tool:
| Input | Output | Effect |
|---|---|---|
let a = 1 newline let b = 2 | let a=1 newline let b=2 | Still valid |
return newline 1; | return newline 1; | Meaning unchanged |
let d = a - -b; | let d=a- -b; | Still valid |
if (x) /a b/.test(y); | if(x)/a b/.test(y); | A regular expression right after a closing parenthesis can be read as division, so its spacing changes |
For production builds, use a parser-based minifier.
What else it will not do
- Variables are never renamed and dead code is not removed, so results are much larger than from Terser or esbuild. Use one of those for anything you ship regularly.
- All comments go, including
/*! license */banners you may be required to keep. - Beautify's spacing is approximate. It writes things like
i ++,const f =(x) => x * 2;anda ?.b, and leavescaselabels at the same indent as the switch. It reads fine but will not match your code style. - Beautify drops line breaks too, so code with no semicolons is joined up: three statements become
let a = 1 let b = 2 foo()on one line. - JSX and TypeScript are not understood. Apostrophes in JSX text can be mistaken for strings.
Before you ship the output
How do I know the output still works?
Run it, or paste it into your editor or a linter. The page itself cannot tell you. The Code Diff Viewer can help you compare a re-beautified copy against the original.
Does the Savings figure match what users will download?
No. It compares character counts before any network compression. Try the GZIP tool to estimate transfer size.
Why is my output still several lines long?
Line breaks inside template literals are part of the string, so they are kept.
For stylesheets and markup, the CSS Minifier and HTML Beautifier do the same kind of cleanup.