All Tools View Categories About Contact Privacy

Terraform Fmt / Validate Command Builder

Assemble a terraform fmt or terraform validate command.

Runs entirely in your browser - nothing is uploaded and no Terraform connection is made.
0
flags
0
chars
Your terraform fmt/validate command will appear here.

About Terraform Fmt / Validate Command Builder

The Terraform Fmt / Validate Command Builder assembles a correct terraform fmt or terraform validate command from a simple form. Pick the mode, toggle the relevant flags, optionally supply a directory, and the tool produces a copy-ready command line. This removes guesswork about flag spelling and ordering, which is easy to get wrong when you are moving between terminals, CI shells and documentation snippets. Because the two commands share a name but accept completely different flags, mixing them up is a common mistake that this builder prevents by hiding the irrelevant options.

terraform fmt rewrites HCL source into a canonical layout so that pull requests stay readable and diffs stay focused on real changes. terraform validate checks that the configuration is internally consistent and syntactically valid before you ever pay for a plan. Both are fast, local, read-only steps that are safe to run on untrusted input, which makes them ideal gates in continuous integration. The builder validates the inputs you provide: the fmt indent must be a non negative integer, and each validate variable must be in key equals value form. Everything runs in your browser, so no state is read, no cloud is contacted, and nothing is uploaded. There is no need to install Terraform just to discover the right spelling of a flag.

Use this tool when you are writing a pre commit hook, a CI workflow, or a documentation snippet and want a command you can trust. It is also handy for teaching, because the flag summary makes the available options explicit instead of hidden in a man page. The output is plain shell text, so you can paste it straight into a Makefile, a GitHub step, or a local terminal. When a teammate copies your command they get exactly what you intended, with no silent reformatting surprises from a misremembered switch.

Features

  • Two modes - choose fmt or validate and the form adapts.
  • All fmt flags - -recursive, -diff, -check, -write=false, -list=false and -indent=N.
  • All validate flags - -json, one or more -var-file paths, and -var key=value pairs.
  • Directory argument - append an optional path to target a sub folder.
  • Input validation - indent must be a number, vars must be key=value.
  • Live stats - see the selected flag count and the command length.
  • Word wrap toggle - wrap long commands in the preview for easy reading.
  • Shell quoting - paths and values with spaces are quoted automatically.
  • Mode aware - only the flags for the chosen mode are offered.
  • Copy / Download / Print - export the command wherever you need it.
  • Private - assembled locally, nothing leaves the page.
  • CI ready - output drops straight into a workflow step.
  • Zero install - no Terraform binary required to build the line.
  • Reproducible - the same inputs always produce the same command.

How to Use

  1. Pick the mode with the Mode select: fmt or validate.
  2. Toggle fmt flags when in fmt mode: recursive, diff, check, write=false, list=false, and set an indent number if needed.
  3. Toggle validate flags when in validate mode: enable json, list var files one per line, and list variables as key=value one per line.
  4. Add a directory in the optional Directory field to target a specific module path.
  5. Click Build command to generate the shell line in the preview.
  6. Read the live stats to confirm how many flags were selected and how long the command is.
  7. Toggle word wrap if the command is too wide to read comfortably.
  8. Review the error panel if the indent or a variable is malformed.
  9. Export with Copy, Download as a shell snippet, or Print.
  10. Start over with Clear, or reload a realistic setup with Load sample.

Examples

Example 1 - fmt recursive with diff. Mode fmt, recursive and diff checked, no indent, directory set to a dot produces terraform fmt -recursive -diff. This is the canonical pre commit check that shows what would change before you commit.

Example 2 - validate with json and vars. Mode validate, json checked, var file prod.tfvars and var environment=prod produce terraform validate -json -var-file=prod.tfvars -var=environment=prod. Because the value has no spaces it is not quoted; a value such as us east would be quoted automatically to keep the shell happy.

Example 3 - indent customisation. Mode fmt with -indent=4 changes the canonical indentation that fmt applies, which is useful when a repository standard differs from the default two spaces.

Benefits

  • Correct syntax - flags are assembled per mode, never mixed.
  • Validated input - indent and variable form are checked.
  • Fast - a command line is built instantly in the browser.
  • Portable - copy, download or print the result.
  • Private - no upload, no Terraform connection.
  • Teachable - the flag set is made explicit and visible.
  • Consistent - every team member ships the same command shape.

Frequently Asked Questions

What does terraform fmt do?
terraform fmt rewrites HCL configuration files to a canonical format and style.
What does terraform validate do?
terraform validate checks whether the configuration is syntactically valid and internally consistent.
What fmt flags are supported?
-recursive, -diff, -check, -write=false, -list=false and -indent=N.
What validate flags are supported?
-json, -var-file and -var.
Does this connect to Terraform?
No. The command is assembled in your browser and nothing is uploaded.
Can I download it?
Yes. Copy the command, download it as a shell snippet, or print it.