Skip to content

JavaScript Minifier and Beautifier

Compress a script for production with Terser, or format minified code so you can read it. Your code stays in your browser and is only parsed, never executed.

Renames local variables and parameters. Top-level names stay the same, so other scripts can still use them.

Comments containing @license, @preserve or @copyright, or starting with /*!

Your code is only parsed and rewritten. It is never run.

Processed in your browser. Your code is never uploaded.

How to minify JavaScript

  1. 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.
  2. Choose Minify or Beautify. In Minify mode, set Shorten variable names, Remove console.* calls and Keep licence comments the way you want.
  3. Read the result on the right, with the size before and after and the percentage saved.
  4. 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 true written 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, @preserve or @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.

Frequently asked questions

Which minifier does this tool use?

It uses Terser, the JavaScript minifier behind most modern build tools. It parses your code into a syntax tree, simplifies it and prints it back in the fewest characters it can. The output does the same thing as your original code, as long as the code doesn't depend on things like function names read at run time.

Does the tool run my JavaScript?

No. Your code is parsed and rewritten as text, but never executed. Nothing in it can access the page, make network requests or show pop-ups. That is why you can safely paste scripts you are still debugging, or code you found and want to inspect.

What does Shorten variable names do?

It renames local variables, function parameters and private class fields to one or two letters, which is usually the biggest saving. Names at the top level of the script, such as a global function or a const declared outside any function, are kept, so other scripts and inline event handlers that refer to them keep working. Object property names are never renamed.

What does Remove console.* calls remove?

Every call to console.log, console.warn, console.error and the other console methods is removed, including the arguments inside the brackets. If an argument calls a function that has side effects, such as console.log(save()), that call disappears too, so check for this before switching the option on.

Which comments are kept?

With Keep licence comments on, comments that contain @license, @preserve or @copyright, or that start with /*!, stay in the output. All other comments are removed. Switch the option off to remove every comment.

Can it minify TypeScript, JSX or modern syntax?

Modern JavaScript, including classes, arrow functions, async functions, optional chaining and import and export statements, is supported and kept as it is: the minifier doesn't convert new syntax for old browsers. TypeScript and JSX are not JavaScript, so compile them first. The Beautify mode does accept JSX.

What if my code has a syntax error?

You'll see the parser's message together with the line and column where it stopped, and the line itself with a caret under the problem. Fix that spot and the result updates by itself. Typical causes are a missing bracket, a stray comma or a TypeScript type annotation.

Can't find the tool you need, or something isn't working?

Tell us which tool you'd like next or what went wrong. We read every message, and requests decide what we build next.

Opens your email app. Please don't attach private files.