Code beautifier & minifier
Beautify or minify HTML, CSS, JavaScript and JSON with your choice of indent, line wrapping and blank lines. See the size saved, then copy or download the result. Runs entirely in your browser.
Open Code beautifier & minifier →What is the code beautifier & minifier?
A tool that tidies or shrinks HTML, CSS, JavaScript and JSON. Beautify re-indents cramped or minified code so it is easy to read, with your choice of indent, line wrapping and blank lines. Minify strips comments and unnecessary whitespace to make files smaller, and shows the size before and after with the percentage saved. Everything runs in your browser, so your code is never uploaded and the tool works offline.
How to use Code beautifier & minifier
- Paste or open your code — Paste code into the Input pane, or use Open file to load an .html, .css, .js or .json file. The language is detected automatically, or you can pick it from the Language menu.
- Set the layout — Choose 2 spaces, 4 spaces or a tab for indenting, an optional line length to wrap at, and whether to keep the blank lines already in your code.
- Beautify or minify — Click Beautify to lay the code out neatly, or Minify to make it as small as possible. The result appears in the Output pane with the size before and after.
- Copy or download — Use Copy to put the result on the clipboard, or Download to save it with the right extension. Use output as input lets you run another pass on the result.
Frequently asked questions
Is my code sent to a server?
No. Beautifying and minifying both happen in your browser, so your code never leaves your device and the tool works offline once it has loaded.
How is JavaScript minified?
With Terser, which parses the code, removes comments and whitespace, and shortens local variable names without changing what the code does. If the code has a syntax error, the message shows the line and column instead.
Is HTML and CSS minification safe?
It is deliberately conservative. Comments and extra whitespace go, but strings, attribute values and the contents of pre, textarea, script and style elements are left exactly as they are, and values such as colours and units are not rewritten.
Does JSON keep large numbers exactly?
Yes. JSON is checked for errors and then re-spaced character by character, so big integers, decimals and key order are kept exactly as written.
Tips
- Beautify a minified file before debugging it — the line numbers in error messages then point somewhere useful.
- Minify only a copy of your code: keep the readable original for editing.
- Invalid JSON is reported with the line and column of the first problem, usually a missing comma, quote or bracket.