
Minifying JavaScript means shrinking the source without changing what it does: comments are removed, whitespace is dropped and expressions are compressed. The result downloads and parses faster. The tool below minifies code you paste, or formats compact code so you can read it. It runs in your browser, so your code is not sent anywhere.
JavaScript minifier and beautifier
Shrink JavaScript for production, or lay it out with indentation to read it. The code is parsed, never run.
Working...
What you enter never leaves your browser. Nothing is sent or stored.
How to use the tool
- Paste your JavaScript into the input field.
- Press Minify for the compact version, or Beautify for an indented, readable one.
- Copy the result. If the code has a syntax error, the tool shows the parser's message instead of output.
Minify uses Terser, a widely used JavaScript minifier, with compression on and comments removed. Variable and function names are left as they are. Beautify reformats the code with two-space indentation.
What it does not do
Because names are not shortened, the output is larger than what a production build produces, where renaming local variables is usually the biggest single saving. The tool also does not bundle files, remove unused modules or produce source maps. It works on one piece of code at a time. For a real application, let your build tool minify on every release, and use this page for snippets, bookmarklets, embedded scripts and quick size checks.
Things to watch
- Test the output. Minification is meant to be safe, but a minified script is still a different file. Run it before you rely on it.
- Syntax errors stop the run. The code is parsed before it is minified, so a missing bracket shows up as an error message and no output. Fix it in the source.
- Comments are removed. That includes license notices. Add them back if your license requires it.
- Minifying is not obfuscation or security. Anyone can run Beautify on minified code and read it. Do not put secrets, keys or private logic in client-side JavaScript.
- Keep the source. Debugging minified code is painful. Keep the readable original and generate the minified file from it.
When to use which
Beautify is the one people reach for most: an inherited one-line script, a snippet from a network panel, a third-party file you want to understand. Minify is for small things you place by hand, such as an inline script in a template.
If shipping and maintaining your front end has become slow or fragile, our web application development and DevOps services cover the build and release side too.
Frequently asked questions
Does my code leave my browser?
No. Minifying and formatting both run in the page on your device. Nothing is sent or stored.
Will minified code behave the same?
It is meant to. Terser compresses code while keeping its behavior, and this tool leaves names unchanged, which avoids a class of problems with code that reads function or variable names. Still, test the result, especially for code that depends on eval or on names being preserved.
Why is the output not much smaller?
Variable names are not shortened here, which is where much of a production build's saving comes from. Server compression (gzip or Brotli) then shrinks the file further, and the two work together.
Can Beautify bring back my original code?
It makes minified code readable again with line breaks and indentation. It cannot restore comments or any names a build tool had already shortened.
Does it work with TypeScript or JSX?
No. It expects plain JavaScript. Compile TypeScript or JSX first, then minify the output.
Keep reading
The articles that follow this one.



