Pretty-print or minify JavaScript instantly in your browser, correctly handling strings, template literals, regex, and comments.
Updated
/ 5 - Be the first to rate this tool Thanks for rating!
Verification failed - please try again.
Quick check
Please verify you're not a robot to submit your rating.
Give feedback
Tell us what you think about Format and minify JavaScript online.
- Runs entirely in your browser — your code is never sent to a server
- Correctly handles strings, template literals, regex, and comments
- Free, no account required
How it works
-
1
Paste JavaScript into the Input box.
-
2
Choose an indent width.
-
3
Press Format to lay it out, or Minify to compress it.
-
4
Copy the result into your editor.
About the JavaScript Formatter
Bundled scripts, snippets from a browser console and code pasted from chat often lose their line breaks. This formatter puts each statement and each block on its own line and indents code inside braces, so you can follow the logic again. It reads strings, template literals, regular expressions and comments as single units, which stops a brace or semicolon inside them from breaking the layout.
What you can do
- Break code at semicolons and braces, indenting blocks with 2 spaces, 4 spaces or tabs.
- Leave the semicolons inside for loop headers on one line, since they sit inside parentheses.
- Keep string, template literal and regular expression contents exactly as written.
- Minify by removing comments and collapsing runs of whitespace into single spaces.
When it works best
- Reading a short minified function from a third-party script or a bookmarklet.
- Making sense of a one-line snippet someone pasted into a ticket or chat.
- Squeezing a small script onto one line for an HTML attribute or a quick console paste.
Things to know
- The code is never executed or uploaded; it is tokenised in your browser.
- This is a lightweight layout tool, not a full parser like Prettier. Object literals are broken across lines like blocks, and code is not checked for errors.
- Minify does not rename variables or remove dead code. It also joins lines, so code that relies on automatic semicolon insertion can break; add semicolons first.
- For JSON data rather than code, the JSON Formatter validates as it formats.
Frequently asked questions
No, it is a lightweight layout tool. Object literals are broken like blocks and code is not checked for errors.
Code relying on automatic semicolon insertion can break when lines are joined. Add semicolons first.
No, strings, template literals and regular expressions are kept exactly as written.
No, it is only tokenised in your browser.