Web Formatter
Indent or minify HTML and CSS. No third-party script sees your code.
Whitespace is not the same in HTML and CSS
This is the difference that decides how far a minifier can safely go, and it is why HTML never shrinks as much as CSS.
In CSS, whitespace between tokens carries no meaning at all. Every space around a brace, a colon or a semicolon can be removed and the stylesheet behaves identically, which is why minified CSS is so dense.
In HTML it is different. A space between two inline elements is rendered as a space on the page, so <b>one</b> <b>two</b> and <b>one</b><b>two</b> do not look the same. A minifier that deletes it changes the page. Runs of whitespace are therefore collapsed to a single space here rather than removed, which is the safe transformation.
What is deliberately left alone
The contents of <pre>, <textarea>, <script> and <style> are preserved exactly. In the first two, whitespace is content and reindenting it changes what the reader sees. In the last two, the content is a different language, and blindly indenting it risks breaking a template literal or a regular expression.
Void elements such as <br>, <img> and <input> never open a block, so they do not push the indent level. Getting that wrong is what makes some formatters produce a staircase that drifts further right down the file.
Why the formatter is not loaded from a CDN
Most online beautifiers pull a large formatting library from a content delivery network. That library then runs in the same page as whatever you pasted, with full access to it. Code pasted into a formatter routinely contains an internal hostname, an API key left in a config block, or a comment naming a system that is not public.
The pass here is written into the page instead. It is smaller and less clever than a dedicated library, and in exchange nothing third-party executes alongside your code, the page stays a single request, and the tool keeps working with no network connection at all.
What it does not do
It does not validate. Unbalanced tags produce odd indentation rather than an error, which is often the first hint that something is wrong but is not a substitute for a validator. It does not reformat JavaScript beyond leaving it untouched inside a script block, because doing that safely needs a real parser rather than a set of rules about braces.
For production, a build step is the right answer. It runs on every deploy without anyone remembering, and it can do things a text pass cannot, such as removing rules no page uses. This tool is for the one-off jobs: making a minified file someone sent you readable, or shrinking a snippet before pasting it somewhere with a size limit.
How to use it
Paste and press Format or Minify. Detect guesses the language from the content, which is reliable enough in practice; set it explicitly if a fragment could plausibly be read either way. Use result as input moves the output back up, which is the quick way to minify something you have just formatted and confirm it round-trips.
Questions
Is my code sent anywhere?
No. The formatter is written into the page itself rather than loaded from a content delivery network, so no third-party script runs alongside your code. Nothing is transmitted, logged or stored, which matters because pasted code so often contains an internal URL or a key.
Why does minified CSS get smaller than minified HTML?
CSS whitespace is almost entirely insignificant, so nearly all of it can go. In HTML a space between two inline elements is rendered, so removing it changes the page. The HTML minifier here therefore collapses runs of whitespace to a single space rather than deleting them.
Will formatting change how my page renders?
It can, in one specific case: adding line breaks between inline elements introduces whitespace that the browser renders. The formatter therefore leaves the contents of pre, textarea, script and style untouched, and keeps inline elements on the line they were on.
Does it validate my code?
No. It reformats what you give it and does not check whether the markup is valid or the CSS is understood by any browser. Unbalanced tags will produce odd indentation, which is often the first sign that something is wrong.
Should I minify by hand for production?
Not usually. A build step does it consistently on every deploy and can do far more, including removing unused rules. This tool is for the one-off cases: inspecting a minified file someone sent you, or shrinking a snippet before pasting it somewhere with a size limit.
Related tools
Browse all Sigma Wire tools - every free tool on the site, grouped by category.