Skip to main content

Terraform Formatter

Format and beautify HCL (HashiCorp Configuration Language) source — the same spirit as `terraform fmt`: align `=` signs within blocks, normalize indentation, reorder meta-arguments (count/for_each first, lifecycle/provisioner last), and optionally sort attributes alphabetically. Includes basic syntax validation. Runs entirely in your browser.

Input

Drop a file or browse
One file · text
Or

Output

Validation
Issue
No data yet
Formatted Terraform
 
Was this helpful?

Guides

Paste inconsistently indented HCL (HashiCorp Configuration Language) and get back a cleanly formatted .tf file — in the same spirit as terraform fmt: = signs aligned within each block, consistent 2-space indentation, count/for_each moved ahead of ordinary arguments and lifecycle/provisioner/connection moved after them (Terraform's documented style guide order), and blank lines separating nested blocks. A quick validation pass flags unbalanced braces/brackets/parentheses, an unterminated string, and an unterminated block comment. Everything runs locally in your browser.

How to use it

  1. Paste your Terraform (.tf) source, or upload a file.
  2. Turn on Sort Attributes Alphabetically to reorder each block's arguments A→Z instead of the default canonical meta-argument order — handy for a large variable/resource block where alphabetical is easier to scan than source order.
  3. Check the Validation panel for any syntax issues, then copy or download the formatted result.

What it formats

  • resource, data, variable, output, module, provider, terraform, and any other labeled or bare block, including nested blocks (lifecycle, dynamic, provisioner, …).
  • Attribute assignments, with = aligned to the longest key in the same block.
  • Inline lists ([...]) and object/map literals ({...}), wrapping a list onto multiple lines once it gets long.
  • Line (#, //) and block (/* */) comments — both standalone and attached to the statement they lead or trail.
  • Heredoc strings (<<EOF ... EOF, <<-EOF ... EOF) are passed through verbatim — their interior is never re-indented, since heredoc content is often meaningful (embedded YAML/JSON/shell).

Does it validate the configuration semantically?

No — this checks syntax, not whether a resource type or attribute is valid for a given Terraform provider. It flags structural problems (unbalanced {}[](), an unterminated string or comment) but won't catch a typo'd argument name or an invalid reference. For real validation, use terraform validate or terraform plan.

Is my configuration uploaded anywhere?

No. Tokenizing, parsing, and formatting all run locally in your browser; your Terraform source is never sent to a server.

Need to work with other infrastructure-as-code formats?

Use the Prisma Schema Formatter or the Ansible Playbook YAML Formatter for other declarative config formats, or the Jsonnet Formatter & Evaluator if your workflow generates JSON/Kubernetes manifests from a templating language instead.

terraformhclformatterinfrastructure as codedevopsbeautify

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.