How to minify JavaScript
- Paste your code into the Your JavaScript box, drop a .js file on it, or press Open file. Try an example loads a short script.
- Choose Minify or Beautify. In Minify mode, set Shorten variable names, Remove console.* calls and Keep licence comments the way you want.
- Read the result on the right, with the size before and after and the percentage saved.
- Copy it or press Download .js. If there is a syntax error, the message below the boxes shows the line and column.
Features
- Terser minification: whitespace and comments removed, constant expressions folded, unreachable code and unused local variables dropped, and
truewritten as!0. - Name shortening for local variables and parameters, with top-level names left alone.
- Console removal for production builds.
- Licence comments kept when they contain
@license,@preserveor@copyright, or start with/*!. - Beautify with Prettier (Babel parser), with 2-space, 4-space or tab indentation. JSX is supported here.
- Exact error locations, with line, column and a marked excerpt.
- Size before and after so you can see what minifying saves.
Why use Fileora's JavaScript minifier
Pasting source code into an unknown website is a real risk: it may contain API endpoints, internal logic or keys that should never have been there. Fileora loads Terser and Prettier into your browser and processes everything locally. Nothing is uploaded, nothing is stored, and your code is never run.
It is also honest about what it did. The options are plain switches with a sentence explaining each one, and the result is the unmodified output of Terser, so it matches what you would get from the same settings in a build tool.
What the minifier doesn't do
This is a single-file minifier, not a bundler. It doesn't follow import statements, combine files, remove unused exports from other modules or create a source map. It doesn't transpile, so code written for modern browsers stays modern. Top-level names are kept on purpose, which means a script full of global functions shrinks less than a module would. And it can't obfuscate: minified code is harder to read but can always be formatted back, which is exactly what Beautify mode does.
For the rest of your front end, compress stylesheets with the CSS minifier and clean up markup with the HTML formatter. To compare the original and minified versions line by line, use the diff checker.
Reading minified code
Got a one-line script from a website or an npm package? Switch to Beautify and paste it in. Prettier re-indents it and puts each statement on its own line. Variable names that were shortened stay short, because the original names are gone, but the structure becomes easy to follow.