All Tools View Categories About Contact Privacy

Terraform fmt Checker

Paste Terraform (.tf) and see whether terraform fmt would reformat it, plus the normalized output.

Runs entirely in your browser - nothing is uploaded and no cloud connection is made.
no
would reformat
Your formatted output will appear here.

About Terraform fmt Checker

The Terraform fmt Checker pastes your Terraform configuration and shows whether terraform fmt would reformat it, together with the normalized output. It is a private, client-side approximation of terraform fmt that parses your HCL and re-emits it with canonical formatting, then tells you if the file would change.

The checker normalizes layout: two-space indentation, a space around the equals sign, and consistent block structure. It does not implement every nuance of the Go formatter that ships with Terraform, but it is close enough to preview formatting issues during a review or when you cannot run Terraform locally. Nothing is written to disk and nothing is uploaded; the result is displayed and can be copied, downloaded as a .tf file, or printed. It is a fast way to keep a pull request tidy and to teach the canonical HCL style.

The tool is particularly handy in code review. Instead of installing Terraform to verify a contributor formatting, a reviewer can paste the diff into the checker and immediately see whether fmt would touch it. That keeps review comments focused on logic rather than whitespace, and it reduces the number of CI failures caused by a forgotten terraform fmt. It also helps new contributors learn what canonical HCL looks like before they ever run the command.

Because the checker is an approximation, treat a YES result as a strong hint rather than a guarantee. For an authoritative answer in automation, run terraform fmt -check in your pipeline; use this tool for fast, local, pre-commit feedback when Terraform is not installed or when you want a quick second opinion on a snippet.

Features

  • Canonical output - two-space indent and a space around equals.
  • Changed flag - tells you whether formatting differs.
  • Preview - shows the normalized .tf text.
  • Built-in parser - no Terraform install required.
  • Export - copy, download as .tf, or print.
  • Client-side only - parsed in your browser.
  • No writes - nothing is changed on disk.
  • No cloud connection - paste and check locally.
  • Private - nothing leaves the browser.
  • Review aid - catch style issues before merge.
  • Review friendly - verify formatting without installing Terraform.
  • Pre-commit feedback - catch style issues before you push.
  • Side by side - compare the original and normalized text quickly.
  • Deterministic - the same input always formats the same way.

How to Use

  1. Open the checker and paste your .tf into the input box.
  2. Click Check to parse and reformat the configuration.
  3. Read the changed flag to see whether fmt would alter the file.
  4. Review the formatted output in the preview panel on the right.
  5. Compare the output with your original to spot the differences.
  6. Export the result with Copy, Download as .tf, or Print.
  7. Start over with Clear, or load a sample with Load sample.
  8. Fix the file by applying the normalized output to your project.
  9. Re-run the checker to confirm the file is now clean.
  10. Share the normalized file with a teammate who lacks the Terraform CLI.

Examples

Example - messy file. A resource written as resource "aws_instance" "web"{ with ami="ami-123" and no spaces around equals is normalized to two-space indent and spaced equals, and the changed flag reports YES.

Example - clean file. A file already in canonical style is reported as unchanged, confirming it would pass terraform fmt -check in CI without any edits.

Example - nested blocks. A configuration with misaligned sub-blocks and inconsistent spacing is re-indented so every level lines up, making the canonical shape obvious and easy to copy back into your editor.

Example - trailing newlines. Inconsistent blank lines are collapsed so the file ends cleanly, which is one of the smaller but common differences fmt enforces across a repository.

Example - list alignment. A list of strings with mixed spacing is re-quoted consistently, so the diff produced by the checker matches what the real formatter would generate in most everyday cases.

Benefits

  • Fast - instant formatting preview.
  • No secrets sent - everything stays local.
  • Clear - an explicit changed indicator.
  • CI friendly - mirrors terraform fmt -check.
  • Private - no uploads or cloud connections.
  • Teaching aid - learn the canonical HCL style.
  • Cheap - no Terraform binary required.
  • Consistent - promotes one HCL style across a team.
  • Deterministic - repeatable output for any input.
  • Lightweight - runs in any modern browser with no setup.

Frequently Asked Questions

What does this tool do?
It parses your .tf and re-emits it with canonical formatting (2-space indent, spaced equals, ordered structure) to show what terraform fmt would produce.
Is it a real terraform fmt?
It is a close client-side approximation. It normalizes layout but does not implement every nuance of the Go formatter.
Does it change my files?
No. It only displays the normalized output - nothing is written to disk or uploaded.
Why would I use it?
Quickly preview formatting issues in a PR review or when you cannot run terraform locally.
Can I export the result?
Yes. Copy, download as .tf, or print.