JavaScript Formatter
Format or minify JavaScript code with basic indentation — no external library required.
How to use this tool
- 1Paste JavaScript into the left 'Input JavaScript' panel.
- 2Click Format to apply basic indentation, or Minify to compact it.
- 3Copy the result from the right Output panel.
About JavaScript Formatter
Quickly readable JavaScript is important when debugging minified code or reviewing a snippet. This formatter applies a character-by-character parsing approach: it tracks string literals (single quotes, double quotes, template literals) to avoid treating braces inside strings as structural, increments indent depth on { and [, decrements on } and ], and adds a newline after each semicolon. The result is a basic but functional indentation that makes most JavaScript readable. Minify strips single-line comments (//), block comments (/* */), and collapses whitespace runs to a single space. For production code formatting with full AST-based accuracy, use Prettier or ESLint. This tool is best for quick inspection of minified snippets or small scripts. Runs entirely in your browser.