Tested in November 2026. Format, minify, the size report and error messages were tested with sample code. The formatting and minifying libraries are loaded from a public CDN when you use the tool.
How to format or minify JavaScript
- Paste your JavaScript into the left box.
- To make code easy to read, choose the indent size and click Format code.
- To make code smaller, click Minify code. Turn on Shorten variable names for a smaller file.
- Check the size shown below the boxes, then click Copy result or Download .js.
Tips for better results
- Format code before you review or debug it.
- Keep a copy of your original file. Minified code is hard to read.
- Test the minified file in a browser before you publish it.
- Leave Shorten variable names off if your code reads function or variable names as text.
Limits to know about
- The tool does not check logic or style. It only reformats or shrinks valid code.
- Minifying invalid code shows an error with the line and column. Formatting may still run on code that has a small mistake.
- Shortening variable names can break code that depends on names, such as some older libraries.
- The first use needs an internet connection to load the formatting library.
Privacy
Your code is processed inside your browser and is not sent to ToolsRiver. Only the open-source libraries are downloaded from a public CDN.
Frequently asked questions
What is the difference between format and minify?
Format adds spaces and line breaks so people can read the code. Minify removes them to make the file smaller.
Will minifying change how my code works?
It should not for valid code, but test it. Shortening names is the step most likely to cause trouble.
Does it support modern JavaScript?
Yes, including arrow functions and const and let.
Can it format JSON?
It can format JSON that is written as JavaScript. For JSON use the JSON Viewer and Formatter on this site.
Is it free?
Yes, with no sign-up.
About this tool
ToolsRiver JavaScript Formatter and Minifier makes code readable or smaller with open-source tools that run in your browser.