JavaScript Formatter
Format and minify JavaScript snippets for quick readable browser-side cleanup.
- Beautify JS
- Minify JS
- Syntax Hints
- Copy
- Private
Choose an action to generate output.
Format real JavaScript syntax without regex rewriting
Prettier parses JavaScript, JSX, TypeScript, or TSX and reprints the syntax using the selected indentation, line width, quote, comma, parentheses, semicolon, spacing, and line-ending options.
Terser powers JavaScript minification with separate whitespace-only, compression, and compression-plus-mangling modes so optimization is always an explicit choice.
How to format or minify JavaScript
- Paste source, open or drop a supported file up to 2 MB, or load a JavaScript, JSX, TypeScript, or error example.
- Choose Format or Minify. Formatting supports automatic JavaScript or TypeScript parsing and detailed style controls.
- For minification, choose whitespace-only, expression compression, or compression with identifier mangling and decide which comments to retain.
- Run the formatter, review exact syntax errors, output metrics, line-level changes, and the high-level structure summary.
- Copy or download the exact result, or move it back into the source editor for another pass.
Make every transformation visible and intentional
- Use grammar-aware parsing so strings, template literals, regular expressions, comments, JSX, and TypeScript syntax are not rewritten with unsafe whitespace expressions.
- See the parser message plus line and column, then jump directly to the failing source position.
- Compare source and output lines and inspect detected imports, exports, functions, classes, and variables without running the code.
- Keep whitespace-only minification as the safest default and opt into compression or mangling only when desired.
- Preserve exact LF or CRLF output for copy and download while processing source entirely in the browser.
JavaScript Formatter FAQ
Does the formatter support JSX and TypeScript?
Yes. Format mode accepts JavaScript, JSX, TypeScript, and TSX. Auto mode tries the JavaScript parser and then the TypeScript parser.
What is the difference between the minify modes?
Whitespace-only disables compression and mangling. Compress can simplify expressions. Compress and mangle can also rename eligible identifiers.
Can TypeScript be minified directly?
No. This tool formats TypeScript but does not transpile it. Remove types with a TypeScript compiler before using JavaScript minification.
Does formatting change program behavior?
Formatting is designed to reprint the parsed syntax without changing its meaning. Minifier compression and mangling are explicit optimization modes and should be tested with the application.
Is this a linter or type checker?
No. The structure view is a lexical summary, not a lint report, compiler, dependency resolver, or type checker.
Is pasted code executed or uploaded?
No. Source is parsed and transformed locally in the browser. The tool does not evaluate, import, or send it to a server.
Why can a syntax error point to a nearby token?
A parser reports the position where the grammar became impossible to continue, which can be just after the actual missing character.
Help us improve this tool
Please share what we should improve, add, or fix. You can write in the language you are comfortable with. We only save your suggestion and IP address to prevent misuse.