Back to public tools
← All tools
Developer utility

JavaScript Formatter and Minifier

Make JavaScript easier to read, or reduce layout whitespace without aggressive compression. Paste or upload UTF-8 source, choose Script or Module, and copy or download the result. Optional local-name mangling and real source maps are available.

Browser-local parsing. Your code is never executed, imported or uploaded.

Tidy JavaScript without running it

Paste code or choose a file, choose the mode and source type, then select Process JavaScript. Review the output and file-size comparison below.

Up to 256 KiB of UTF-8 JavaScript. Upload .js, .mjs or .txt files. ECMAScript 2022 is supported; JSX, TypeScript and newer syntax are not.

JavaScript options

Off by default. Renaming can break name-dependent integrations and reflection. Top-level, property, function and class names are retained; no property or top-level mangling is offered.

Script is for ordinary code. Module allows imports, exports and top-level await, without running or fetching them. Formatting and minification keep comments except old source-map URL directives. No compatibility conversion or aggressive compression is applied. Downloaded source maps must be attached manually.

How to use JavaScript Formatter and Minifier

Choose code and parsing rules

Paste JavaScript, choose a UTF-8 .js, .mjs or .txt file, or use Try an example. Choose Script for ordinary scripts or Module for imports, exports, import.meta and top-level await. A filename does not silently change that choice.

Choose formatting or minification

Format JavaScript uses 2 or 4 spaces for readable layout. Minify JavaScript prints compact code without aggressive compression. Comments remain, except obsolete source-map URL directives.

Mangle local names is optional and available only when minifying. It can rename local bindings while retaining top-level, property, function and class names. Leave it off when integrations or reflection depend on names.

Generate maps when needed

Generate source map creates a separate debugger map. Include original source in map embeds your input in that downloaded file, making it visible to anyone receiving the map. Enable it only when that is intended.

Download the map separately and attach it manually in your debugger or build pipeline. No inline map or automatic sourceMappingURL is added. Map bytes are separate from JavaScript savings.

Process and save

Choose Process JavaScript, inspect errors or output, then copy or download the JavaScript and optional map. Clipboard access has a manual-copy fallback. Edits clear both outputs. Cancel stops work; Clear starts again and returns to the input.

Example: tidy a small module

Your module imports settings and exports a greeting using optional chaining and a fallback name. Choose Module and Format JavaScript with 2 spaces, then process it.

The result is easier to read, while imports stay as source text. Nothing is loaded or run. Switch to Minify JavaScript for compact output, and leave local-name mangling off unless you need it.

About JavaScript formatting

Formatting changes code layout for reading. Conservative minification reduces layout while keeping names by default. It does not remove dead branches, drop console calls, fold constants or rewrite code for older browsers.

ECMAScript 2022 is supported, including optional chaining, nullish fallback, private fields and module top-level await. JSX, TypeScript, decorators and newer syntax are rejected. This is not a transpiler, bundler, full linter or sanitizer.

Printing may normalize quotes, numbers, parentheses and semicolons. Formatting can increase UTF-8 bytes. Review the result and run your own application checks before using changed code elsewhere.

Code is parsed in a worker rather than evaluated, imported or previewed. Imports and calls in your text cannot trigger requests here. Downloaded JavaScript remains executable elsewhere.

Your source, filename, maps and results stay in browser memory. UTF-8 files are supported; invalid encodings, excessive nesting or unsupported syntax produces an explanation rather than partial output. Source maps may contain no executable mappings for comment-only input.

Engine provenance and redistribution licenses.

Stars and feedback

Loading…

Tool reference #177