
A client-side JavaScript formatter and minifier. Beautify mode adds proper indentation based on braces, brackets, and semicolons. Minify mode strips all comments and unnecessary whitespace. Shows input/output sizes and savings percentage.
Why Use This JS Formatter?
- Two modes — Format for debugging or Minify for production.
- String-aware — preserves content inside quotes and template literals.
- Comment handling — format preserves comments, minify strips them.
- Size savings — shows exact character count reduction.
Key Features
- Brace-Based Indentation: Tracks
{,[,(nesting with 2-space tabs. - String Safety: Detects
",', and backtick strings to avoid false reformatting. - Comment Types: Handles both
//line comments and/* */block comments. - One-Click Copy: Copy the formatted or minified result to clipboard.
How it Works
The formatter walks the code character by character, tracking string state (single/double/template quotes). Opening braces increase indent, closing braces decrease it. Semicolons and commas trigger line breaks. The minifier uses regex to strip both comment styles and collapse whitespace.
Try the JS Formatter
Paste JavaScript code, click “Format” or “Minify”, then copy the optimized result.
简体中文
JavaScript 格式化与压缩工具
在开发可读格式和上线压缩格式之间一键切换 JavaScript 代码。
한국어
JavaScript 포매터 & 미니파이어
JavaScript 코드를 가독성 좋은 형식과 배포용 압축 형식 사이에서 손쉽게 변환합니다.
日本語
JavaScript フォーマット&圧縮ツール
JavaScript コードを読みやすい開発用と圧縮された本番用の形式で切り替えます。