JavaScript Formatter & Minifier

Beautify minified or messy JavaScript with configurable indentation. Minify JS to reduce file size for production. No data leaves your device.

js-formatter.tool
Indent:
Input JavaScript
Output

Unminifying JavaScript

Minified JavaScript is intentionally unreadable — variable names shortened to single letters, all whitespace removed, multiple statements on one line. This tool reverses the process, adding line breaks and indentation to make the code human-readable again. Useful for debugging third-party scripts, understanding how a library works, or reviewing code you did not write.

Minifying for Production

Minified JavaScript loads faster. A typical unminified library might be 80KB; minified it drops to 30KB; minified and gzipped, under 12KB. For scripts loaded on every page, this difference translates directly into faster page loads especially on mobile.

Indent Size and Style

The most common standard is 2 spaces (used by Google, Airbnb and most modern style guides). 4 spaces is the traditional Python and Java convention. Tabs are preferred by developers who use tab-width settings in their editors to personalise the visual indent without affecting the file. The formatter accepts all three.

Frequently Asked Questions

It works on TypeScript syntax for most code — the formatter is not TypeScript-aware but handles standard JavaScript patterns including arrow functions, template literals, destructuring and spread operators. Complex TypeScript-specific syntax like decorators or complex type annotations may not format perfectly. For full TypeScript support, Prettier with a TypeScript config is the recommended tool.
The minifier preserves whitespace inside string literals, regular expressions and template literals because removing it would change the value. It also keeps a space between keywords and identifiers where removing it would create a syntax error (e.g. 'return value' cannot become 'returnvalue').
Yes. All processing runs in your browser using JavaScript. No code is sent to any server — you can verify this in your browser's network tab while using the tool.
Minification removes whitespace and shortens obvious names to reduce file size while keeping code functional. Obfuscation transforms code to make it deliberately difficult to understand — renaming variables to meaningless strings, encoding strings, adding dead code. This tool minifies but does not obfuscate. Obfuscated code can often still be partly formatted for readability, though variable names remain meaningless.
Yes. The formatter handles import and export statements, arrow functions, async/await, destructuring and other modern JavaScript syntax. If you have a specific ES module that does not format correctly, the issue is usually an unusual pattern or a syntax error in the original.
It does not. The formatter only adds whitespace and line breaks — it never changes string contents, quote style or any actual code values. If you see changed quotes, they were already inconsistent in the original or were changed by copy-paste (some text editors auto-convert to smart quotes).