Skip to content
kitty/binDev
Your code stays on this device

Tidy code, or the smallest copy

Paste HTML, CSS or JavaScript to get it neatly indented, or minify it for production and see exactly how many bytes you save.

Language
Action

Switch between format and minify at any time; the result updates as you type.

What formatting does

Formatting only changes whitespace. CSS gets one declaration per line, rules separated by a blank line and media queries and nested rules indented. JavaScript is re-indented by its braces with one statement per line, while strings, template literals, regular expressions and for (;;) headers are left exactly as written. HTML is indented by nesting, with inline elements kept on the same line as their text so the page renders the same, and inline <script> and <style> blocks are formatted with the JavaScript and CSS formatters.

What minifying does

Minifying removes comments and every space the browser does not need. Comments that start with /*! are kept, since they usually hold a license. JavaScript keeps a line break wherever automatic semicolon insertion depends on one, so code written without semicolons still works. Names are not shortened and no code is rewritten, so the result behaves exactly like the original. In HTML, the contents of pre and textarea are never touched, and whitespace between inline elements is kept as a single space so words do not run together.

Limits worth knowing

The formatter reads code with a real tokenizer rather than search and replace, but it does not fully parse it, so it will not catch every syntax error. When it does find a problem, such as an unclosed string, comment or bracket, it tells you the line. TypeScript, JSX and template languages are not supported. HTML minifying removes the gaps between block elements such as list items; if a layout relies on that whitespace between inline-block items, check it after minifying.

Private by design

Your code is formatted on this page in your browser. Nothing is uploaded, so it is safe for private or unreleased work.

more in the bin

Keep going.

More in kittybin Dev

Explore the bin