JS Beautifier / Minifier
Processed Client SideBeautify or minify JavaScript code. Reformats structure with proper indentation or strips it down to the smallest size.
Bookmark this tool now — skip the search next time you need it.
About JS Beautifier / Minifier
This tool runs entirely in your browser. Whatever you paste is processed on your own device and is never uploaded, logged, or sent to any server.
The JS Beautifier and Minifier does the two things you need when handling unfamiliar JavaScript: expand it so you can follow it, or squeeze it so you can ship it. Beautify rebuilds indentation from the structure of the code, spaces operators and keywords consistently, keeps short object literals on one line, and breaks long ones by property. Minify strips comments and indentation but deliberately keeps a newline anywhere that removing it would change automatic semicolon insertion, so code written without semicolons still runs afterwards. Strings, template literals with nested expressions, and regular expressions are recognised as whole tokens and passed through untouched. Both modes run as you type, in your browser.
Key features
- Beautify and minify from one toggle, with the output updating on every keystroke
- Structure-aware indentation for blocks, objects, arrays, classes, and switch cases
- Short object literals and destructuring stay on one line; long ones break by property
- Consistent spacing around operators, keywords, arrow functions, and ternaries, with prefix and postfix operators left tight
- Regex literals, template literals with nested placeholders, and strings pass through character for character
- Comments can be kept or dropped when beautifying, and blank lines you left between statements are preserved
- Minify keeps newlines exactly where semicolon-free code needs them, so the result still parses
- Two-space, four-space, or tab indentation, with syntax highlighting in both panes
- Runs entirely in your browser, so nothing you paste is uploaded
How to use it
- Choose Beautify or Minify with the toggle in the toolbar.
- Paste your JavaScript into the left pane.
- For Beautify, pick the indentation width and decide whether to keep comments.
- Read the result on the right, which re-runs as you edit.
- Copy the output with the button on the right of the toolbar.
Tips & common mistakes
- Beautify is the fast way into a minified bundle. Variable names stay mangled, because nothing can bring those back, but the structure becomes readable immediately.
- Minify here is whitespace and comment removal only. It does not rename variables, drop dead code, or tree-shake, so expect a smaller saving than Terser or esbuild in a real build step.
- Comments are always removed when minifying, licence headers included. Keep those somewhere else if the licence requires them to ship.
- The formatter never inserts or removes semicolons. It lays out the code you gave it and nothing more, which is why minified output stays safe for semicolon-free source.
- It is a formatter, not a compiler, so it will happily format code that does not run. Output that indents oddly usually means an unbalanced brace or an unterminated string earlier in the file.
- TypeScript annotations and JSX are treated as ordinary tokens rather than understood, so use Prettier locally for those files.
- Chained calls stay on one line rather than one call per line. That is a layout choice here, not something wrong with your input.