Minify or beautify JavaScript
- Free
- No sign-up
- No upload
- Works offline
Tool facts
- Opens
JSMJSCJS- Saves as
JS- Price
- Free, no sign-up, no watermark
- Are files uploaded?
- No. Everything is processed in this browser, on your device.
- Batch processing
- One file at a time
- Offline use
- Works without a connection once this page has loaded
- Built with
- Terser and js-beautify
- Browser
- A recent Chrome, Edge, Firefox or Safari, on computer or phone.
Check it yourself: press F12, open the Network tab, then use the tool. No request carries your data.
About JavaScript Minifier
JavaScript Minifier shrinks a script with Terser, the same minifier used by Vite, webpack and Rollup, and shows the size before and after. Mangling renames local variables and function parameters to one or two letters, compression rewrites code into shorter equivalent forms and drops unreachable branches such as if (false), and all comments except licence notices are removed by default.
Switch to Beautify to turn minified or badly formatted code into indented, readable JavaScript with js-beautify, which helps when you debug a bundle or read a third-party script. Modern syntax is supported, including ES modules, classes, async functions, optional chaining and private fields. If the code has a syntax error, the status bar shows the line and column. Your code is processed only in your browser.
JavaScript Minifier runs entirely in your browser. Your data is processed on your device and is never uploaded to Qiyi or anyone else.
How to use JavaScript Minifier
- Paste your code into the Input box, or drop a .js or .mjs file onto the page.
- Choose Minify or Beautify under Mode.
- For Minify, switch Mangle names, Compress and ES module on or off and choose which comments to keep. For Beautify, choose the indentation.
- Read the result and the size change, then click Copy or Download.
Frequently asked questions
What do mangle and compress do?
Mangle shortens the names of local variables and function parameters, which is safe because those names are not visible outside their scope. Compress applies code transformations such as removing dead code, joining consecutive var statements, folding constant expressions and simplifying if statements. Global names, exports and object property names are never renamed.
When should I turn off ES module?
Keep it on for code that uses import or export, or that is loaded with script type=module; it also lets Terser treat top-level names as private. Turn it off for classic scripts that define global functions used by other scripts on the page, otherwise those functions could be renamed or removed.
Which comments are kept with Licence only?
Comments starting with /*! and comments containing @license, @preserve or @cc_on are kept, which is what most open-source licences require. Choose None to strip everything or All to keep every comment.
Can beautify restore the original variable names?
No. Beautify restores indentation and line breaks, but names shortened by mangling are lost. To get the original source you need the project's source map or source files.
Does it support TypeScript or JSX?
No. Terser expects standard JavaScript, so TypeScript types and JSX tags cause a syntax error. Compile them to JavaScript first, for example with tsc, esbuild or Babel.