Code Formatter and Minifier
Minify only removes whitespace and comments. It is not obfuscation, so variable names stay as they are.
Enter code, then press Run
Enter code, then press Run
How to Use
📖 Overview
Code copied from somewhere else usually arrives as a wall of text with no indentation, or with line breaks that made sense in a different editor and make no sense in yours. This tool re-indents HTML, CSS and JavaScript, or does the opposite and squashes a file down to a single line ready to ship. While formatting it tracks lexical state, so a brace inside a string literal or a semicolon inside a quote is left alone instead of being treated as syntax. While minifying it keeps a single space wherever two identifiers would otherwise fuse into one token, so you do not end up with a keyword glued to a variable name. Everything happens locally in the browser, so your source never leaves the machine, which matters when you are pasting something proprietary. It is a formatter, not a parser: it rearranges whitespace and leaves the meaning of your code exactly where it was. That distinction is worth keeping in mind, because a formatter will happily tidy up a file that does not compile, and it will not tell you that anything is wrong. What it does promise is that the characters it removes or inserts are whitespace and nothing else.
✨ Features
- Handles HTML, CSS and JavaScript, each with its own line-breaking and indenting rules rather than one shared routine, so a CSS block and a JavaScript block never get treated the same way
- Works in both directions: expand into a readable multi-line structure, or compress onto one line to cut bytes
- Indentation of 2 spaces, 4 spaces or a tab, so the output matches your existing project style
- Lexically aware: string literals and comments are skipped, so brackets and semicolons inside them are never mistaken for syntax
- Comments can be kept or dropped during minification, and a blank line can be inserted between CSS rule blocks
- Size comparison: input characters, output characters and the percentage saved, plus how the line count changed
🚀 How to use
- Paste your code into the input box, or load the sample to see what each mode does
- Select the language: HTML, CSS or JavaScript
- Choose pretty-print or minify, and if pretty-printing pick an indent width
- Optionally tick keep-comments and the blank-line-between-CSS-rules option
- Press Run, then copy the result or download it as a file with the matching extension
⚠️ Notes
- Not a compiler: the tool rearranges whitespace based on symbols and performs no syntax check. Code that is already invalid will still be printed, just tidily
- Minify is not obfuscation: only whitespace and comments are removed, and variable names survive untouched. Use a dedicated obfuscator if you need to protect source
- Test after minifying: anything that depends on literal newlines, such as multi-line template strings, should be run once afterwards to confirm behaviour is unchanged
- Very large files stall: formatting a single file of several hundred kilobytes takes noticeable time, so split it into chunks first
- Empty input gives no result: running with a blank box prompts you to enter code rather than returning an empty string, and changing any option after a successful run invalidates the displayed result until you press Run again