Caspian Office

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 →
Private · runs in your browserOffline · after first loadFree · no signup

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

  1. 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.
  2. 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.
  3. 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.
  4. 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

Related tools

← Browse all Caspian Office tools