JavaScript Formatter & Compactor
Beautify JavaScript or JSON with your choice of indentation and brace style, or compact it by removing comments and whitespace while keeping the line breaks the code relies on. Names are never changed.
Free, no sign-up
Saved on your device only
Works offline after first open
The tool
Loading the tool…
How to use
- Paste JS or JSON, or open a file.
- Choose Format and a brace style, or Minify to compact it.
- Copy or download the result.
Privacy & how it works
Saves your data in this browser only (back it up or delete it from “My data”).
- Engine: beautifier (open-source libraries bundled with the site).
- Works offline after you open it once.
Frequently asked questions
Is compacting the same as tools like Terser?
No. It only removes comments, spaces and unnecessary line breaks; it never renames variables or removes code. Files shrink, but less than with full build tools.
Why are some line breaks kept after compacting?
JavaScript sometimes treats a line break as a semicolon (for example after return or before ++). Those line breaks are kept so the code means the same thing.
Does it support TypeScript and JSX?
Formatting works with much TypeScript and with JSX to a limited extent. Compacting is designed for plain JavaScript.
Related tools
HTML Formatter & MinifierBeautify HTML with clear indentation or minify it for production: removes comments and extra whitespace, keeps pre and textarea intact, and safely compacts inline CSS and JS. Fully local.CSS Formatter & MinifierBeautify CSS with clear indentation and one property per line, or minify it for production by removing comments and whitespace without breaking strings, calc() or media queries.Code to ImageTurn code into a clean image for slides, reports and social posts: automatic highlighting for 30+ languages, light and dark themes, a window frame and line numbers, exported as high-resolution PNG or SVG.Regex Tester & LibraryTest a regular expression on your text with live match and group highlighting, plus replace, split, extract to CSV, an escape helper and a library of ready patterns (Saudi mobile, IBAN, email…).