`terraform fmt` Is the Command You Should Run Before You Ask for Review on Infrastructure Code That Still Looks Like Everyone Edited It With Different Rules
A practical guide to `terraform fmt` for normalizing Terraform file formatting so infrastructure review can focus on actual changes instead of spacing and alignment noise.
Why this command matters: infrastructure code review gets worse when formatting noise competes with real resource changes for attention.
terraform fmt applies Terraform’s canonical formatting rules to configuration files. That makes reviews cleaner and reduces pointless style churn in HCL-heavy repos.
The command
terraform fmtFor recursive formatting:
terraform fmt -recursiveThat is particularly useful in larger repos with multiple module directories.
Why it helps
It is useful when:
- multiple contributors edited HCL with different editor behavior
- alignment and spacing noise are making diffs harder to read
- CI enforces formatting
- you want a cleaner pre-review pass on Terraform changes
This is exactly the kind of consistency a tool should own instead of a human reviewer.
Final recommendation
If a Terraform diff looks noisier than the actual infrastructure change, run terraform fmt. It is still one of the easiest ways to make infra review less about whitespace and more about resources, state, and intent.