JavaScript Minifier
Make JavaScript smaller with Terser, without uploading it.
- 100% Free
- No Sign Up
- Works in Your Browser
JavaScript minifier
Minify JavaScript with Terser
Everything runs in your browser. Nothing is uploaded.
More Developer Tools
View all tools- JSON formatterPretty-print and indent JSON
- JSON validatorCheck JSON and find syntax errors
- JSON minifierStrip whitespace from JSON
- XML formatterIndent XML so it's readable
- SQL formatterFormat SQL queries for readability
- Base64 encode/decodeEncode and decode Base64 text
- JWT decoderDecode a JSON Web Token
- UUID generatorGenerate random v4 or time-ordered v7 UUIDs
- Timestamp converterConvert Unix epoch time to dates
Every everyday developer tool, right in your browser.
No installs. No uploads. No signup.
Browse all 36 tools- Developer tools
- 36
- Cheat sheets
- 10
- Bytes uploaded
- 0
How to use the JavaScript minifier
Three steps, all in your browser.
- 1
Paste your input
Type or paste your code or data. Press Sample to try an example.
- 2
Pick the style
Choose indentation or options. The result updates as you type.
- 3
Copy the result
Copy the output in one click. Nothing is saved or sent anywhere.
JavaScript Minifier: what to know
The JavaScript minifier uses Terser, the open-source minifier used by default in many build tools including webpack. It parses your code into a syntax tree, then removes whitespace and comments, shortens names of local variables and functions (mangling), and simplifies code, such as folding constants and dropping code that can never run.
Mangling is safe for names that can't be seen from outside their scope. Top-level names in a classic script are global and other scripts may rely on them, so they're left alone. Property names are never renamed, since code elsewhere can access them by string.
The tool shows the original and minified size. Minified code is hard to debug, so for real projects let your bundler minify on each build and generate a source map; this page is best for one-off scripts, bookmarklets, snippets for a CMS or seeing how small a function can get.
Popular uses
- Minifying a standalone script for a static page
- Making bookmarklets and snippets compact
- Checking the minified size of a function
- Shrinking inline scripts in HTML templates
Tips for the best result
- Comments that begin with /*! or contain @license or @preserve are usually license notices; check the output keeps any your license requires.
- If minified code behaves differently, look for code that relies on function.name or on reading its own source.
- Syntax errors are reported with a line and column so you can fix the source first.
Read how JustYourDev works and our privacy details. Code, data and files you use here are processed in your browser and are never sent to our server.