Swelıty
Tools for everyone

Free Online JavaScript Formatter / Minifier

Format, beautify, and minify JavaScript code.

Input

Output (Formatted)

How to use

  1. Paste your code into the input box, or open a .js file.

  2. Choose Format to make it readable or Minify to make it smaller.

  3. Check the output. If there is a syntax error, its message appears above the editors.

  4. Copy the result or download it as formatted.js or minified.js. Full screen gives you more room.

Why use this tool

  • Prettier formatting

    A consistent layout with single quotes, trailing commas and semicolons.

  • Terser minifying

    Shortens the code and removes comments. Variable and function names are not renamed.

  • Modern syntax

    Newer features such as classes, optional chaining, async functions and private fields are understood.

About this tool

JavaScript Formatter tidies JavaScript or makes it smaller. Format uses Prettier to add line breaks and two-space indentation, which helps when you read a minified file, a snippet from a chat or code with mixed styles. Prettier is set to use single quotes, trailing commas and lines of about 80 characters, and it adds semicolons. Minify uses Terser to compress the code and remove comments, while keeping your variable names. The output updates as you type, and an error message appears if the code cannot be read. The page opens with an example.

Frequently asked questions

Format puts the line breaks and indentation back. It cannot restore the original variable names or removed comments.

Prettier changes layout and style, such as quotes, commas and semicolons, and is designed to keep the behaviour the same.

Terser rewrites expressions and can remove code it can prove is never used. Test the minified file before you publish it.

Name shortening is switched off here. A build tool that renames variables and removes unused imports will usually go further.

Format can read JSX, but Minify expects plain JavaScript. For TypeScript, compile it to JavaScript first.