Terraform HCL Formatter
Format and align Terraform HCL files in your browser like terraform fmt. Block indentation, equals alignment, heredoc support. No upload, 100% client-side.
Loading tool...
What is Terraform HCL Formatter?
The Terraform HCL Formatter is a browser-based formatter for HashiCorp Configuration Language (HCL), the syntax behind Terraform, OpenTofu, and Terragrunt files. It re-indents blocks, aligns equals signs, normalizes spacing, and flags unbalanced braces - everything terraform fmt does for readability, without installing anything or uploading your code.
Key Benefits
- Readable, consistent diffs that speed up code review
- Sensitive infrastructure code stays on your machine - zero uploads
- Catches unbalanced braces and brackets before you commit
- No Terraform CLI or editor plugin installation required
- Compact mode for embedding minimal config in docs and CI logs
Common Use Cases
- β’Cleaning up machine-generated or hastily written .tf files
- β’Normalizing indentation before opening a pull request
- β’Reading dense one-liner Terraform configs from tutorials
- β’Formatting terragrunt.hcl and OpenTofu .tofu files
- β’Preparing readable infrastructure snippets for documentation
How to Use the Terraform HCL Formatter
- Paste your HCL: Open a .tf file (main.tf, variables.tf, outputs.tf) and paste its contents into the input box, or click Sample to try an example.
- Choose a mode: Pick Format for terraform fmt-style indentation and alignment, or Compact for a minimal one-line-per-statement output.
- Set options: Choose a 2 or 4 space indent and toggle equals-sign alignment for consecutive attribute groups.
- Format and copy: Click Format, review the validation warnings if any appear, then copy the result or download it as main.tf.
Key Features
- terraform fmt-style block indentation with 2 or 4 space option
- Automatic equals-sign alignment for consecutive attributes
- Heredoc-aware parsing that keeps <<-EOF blocks byte-for-byte
- Brace and bracket balance validation with line numbers
- Compact mode that strips comments and blank lines
- Copy to clipboard or download as main.tf - no upload, no server