CodePress
Beautify and minify HTML, CSS and JavaScript with configurable rules.
Input code
Result
What is CodePress?
CodePress cleans up HTML, CSS and JavaScript code in two opposite directions: "Beautify" takes messy or compressed code and re-indents it with consistent spacing and line breaks so it's readable, while "Minify" strips out whitespace, comments and line breaks to make the file as small as possible for production. It's meant for whenever code you're given (or wrote in a hurry) doesn't match the formatting you need.
How to use CodePress
- Paste your code into the Input code panel (or click Example), and pick its language — HTML, CSS or JavaScript.
- Choose Beautify or Minify, and an indentation width if beautifying.
- Read the formatted code in the Result panel.
- Click Copy or Download to save it.
How CodePress works
CodePress tokenizes the code respecting strings, comments and (in JS) template literals and regex, then applies indentation rules based on brace/parenthesis depth for "Beautify," or strips whitespace, comments and unnecessary line breaks for "Minify":
/* Before */
.card{color:red;padding:8px}
/* After Beautify */
.card {
color: red;
padding: 8px;
}
JavaScript's compact mode is deliberately conservative (it never merges lines) to avoid ASI bugs; HTML and CSS are compacted aggressively. Everything runs in your browser — no external libraries, no server calls.
Frequently asked questions
Does it use a full parser for each language?
No. It uses a tokenizer and indentation rules based on brace/parenthesis depth, similar to most lightweight online formatters — not a full compiler. Code with very unusual syntax may need manual tweaks.
Is the JavaScript compact mode as aggressive as a production minifier?
Deliberately not: it only strips comments, blank lines and indentation, but keeps the original line breaks between statements to avoid bugs from automatic semicolon insertion (ASI) that an aggressive minifier without a full parser could introduce.
Is HTML and CSS compacting just as conservative?
No, those are minified more aggressively (collapsing whitespace and stripping comments) because HTML and CSS don't have JavaScript's ASI problem — it's safe to compact them fully.
Is it safe to paste proprietary code here?
Yes. All processing happens in your browser; no code is ever sent to a server.