JavaScript Formatter / Minifier
Runs locally in your browser. Your input is not uploaded.Free, no sign-up
Input
Output
Format JavaScript, JSX and TypeScript, or minify JavaScript, without executing it.
How to use the JavaScript Formatter and Minifier
- Paste JavaScript, JSX or TypeScript and pick the Language, or click Sample.
- Choose indentation, quotes and semicolons; the formatted code appears instantly.
- Switch to Minify to shrink JavaScript for production and see the savings.
- Syntax errors are shown with their line and highlighted in the editor.
Your code is never run
Formatting and minifying only parse and rewrite the text. Nothing you paste is executed, so it's safe to paste code you don't trust, such as a suspicious script you're investigating.
Minify options
- Shorten names renames local variables and functions (
message→e). Global names in a script stay, because other scripts may use them; in an ES module (code withimportorexport) top-level names are shortened too. - Compress rewrites code into shorter equivalents, such as removing unreachable code and folding constants.
- Keep license comments keeps
/*! … */,@licenseand@preservecomments, as most licenses require.
Frequently asked questions
Which tools does this use?
Prettier for formatting and Terser for minifying, the same tools most build pipelines use, running in your browser.
Can I minify JSX or TypeScript?
Not directly. Compile it to JavaScript first (for example with your bundler), then minify the result.
Is my code uploaded?
No. Everything happens in your browser.
Related tools
All tools- HTML FormatterFormat and minify HTML and check its basic structure.
- CSS Formatter / MinifierFormat CSS, SCSS and Less, or minify CSS stylesheets.
- JSON FormatterFormat, validate and minify JSON with syntax highlighting and precise error locations.
- Regex TesterTest regular expressions with live match highlighting, capture groups, flags and explanations.
- Cron Expression GeneratorBuild Linux cron expressions with a visual editor and preview the next run times.