Comparison
Minify, format and validate are three different operations
All three take code in and give code back, which is why they get used interchangeably. Only one of them is meant for the file you ship, only one is meant for the file you read, and the third never changes a byte.
Side by side
| Operation | Changes the file? | Output is for | Reversible |
|---|---|---|---|
| Minify | Yes, removes whitespace and comments | The browser | Format it again |
| Format / beautify | Yes, adds whitespace | A human and a diff | Minify it again |
| Validate | No | Finding the error | Nothing to reverse |
The short answer
Minify what you deploy, format what you commit, validate when something will not parse. Two cautions: minifying strips comments, so a licence header disappears unless it is marked to keep; and in HTML, whitespace between inline elements is not decoration, so a minifier that collapses it can visibly close up gaps between words and links.
In more detail
Whitespace is not always decoration
In HTML, the space between two inline elements renders as a space, so a minifier that removes it closes up the gap between words or links. Good minifiers know this and leave it; aggressive settings sometimes do not. In pre and textarea elements every character is significant, and in YAML and Python indentation is syntax.
Minify what you deploy, commit what you can read
A minified file in version control produces a diff nobody can review, which is how a change hides in a one-line file. Keep the readable version in the repository, minify as part of the build, and let the build output be the thing that ships. If a minified file is already committed, formatting it once is a safe one-off.
Validation changes nothing, which is the point
A validator reads and reports; it never writes. That makes it the right first move when something will not parse, because it tells you the line and the character rather than quietly producing something that looks plausible. It is also why running one costs nothing and is worth doing before any conversion.