CalcSnippets Search
Infrastructure 1 min read

`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 fmt

For recursive formatting:

terraform fmt -recursive

That is particularly useful in larger repos with multiple module directories.

Why it helps

It is useful when:

  1. multiple contributors edited HCL with different editor behavior
  2. alignment and spacing noise are making diffs harder to read
  3. CI enforces formatting
  4. 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.

Sources

Keep reading

Related guides