Shrink a JavaScript file with terser and see the size saved
Runs in your browser. Nothing you type is sent anywhere. Updated on 24 Oct 2026.Every kilobyte of JavaScript is a kilobyte the browser must download, parse and run before anything works. This page runs terser over your file: dead code goes, local variables become single letters, and whitespace and comments disappear. You get the size before, the size after and the percentage saved. Turn off renaming if you need the output to stay traceable to the source.
The page opens in Minify mode; paste the script into JavaScript or JSX.
Leave Rename local variables on for the biggest saving, or turn it off to keep the output traceable.
Turn on Keep function names if you need readable stack traces.
Read Before, After and the percentage smaller, then press Copy or Download.
This JavaScript formatter does the two things people want from a script file. Beautify runs Prettier over it and returns the same code laid out your way: two spaces, four spaces or a tab, semicolons or not, single or double quotes, and a line width you choose. Minify runs terser and returns the smallest equivalent file, with the size before, the size after and the percentage saved.
It suits the small jobs that interrupt a day. A snippet copied from an answer online uses a style your project does not. A file you inherited has three statements per line. You need to see roughly how big a helper will be once it ships, before deciding to write it yourself. And sometimes you need the opposite: a minified bundle expanded enough to work out what a third-party script is doing.
Minify has two switches. Renaming local variables to single letters is where most of the saving comes from and changes nothing you can observe from outside. Keeping function names costs a few bytes but leaves stack traces and anything that reads a function's name readable, which matters if you send errors to a monitoring service.
The rest of the article, and all 6 questions about JavaScript Beautifier & Minifier, are on the JavaScript Beautifier & Minifier page.
Yes. No signup, no size limit and no cap on how many files you run through it. The page is paid for by a few ads shown outside the tool, and nothing is inserted into your code.
Readable source with comments usually drops 40 to 60 percent, and much more when it has long variable names and blank lines. Code that is already minified barely changes. The exact byte counts are shown, so you can compare.
Mangling renames local variables and function arguments to single letters. Nothing outside the file can see those names, so behaviour is unchanged, and it is usually the biggest single saving. Exported names and object properties are left alone.
You can get the layout back, not the names. Beautify adds line breaks, indentation and spacing so the code is readable, but a minifier discards the original variable names and comments, and no tool can recover them.
Still stuck? Ask about JavaScript Beautifier & Minifier and anybody who knows can answer. No account needed.
Same job, other tools: JSON Minifier – Strip whitespace from JSON for production · HTML Minifier – Strip comments and spare whitespace from HTML and see the saving · CSS Minifier – Compress a stylesheet and see exactly how many bytes you saved.
On the related tools: GraphQL Validator – Check a GraphQL query or schema for errors, optionally against your own SDL.
In the collection Code Formatters and Minifiers.