Skip to main content

Terraform HCL Formatter

Format and validate Terraform HCL like terraform fmt — right in your browser. Aligns = signs, normalizes indentation, validates syntax, detects deprecated patterns, and extracts variable skeletons.

✓ Aligns = signs per block ✓ Validates HCL syntax ✓ Detects deprecated 0.11 patterns ✓ Extracts variables.tf skeleton ✓ 100% runs in your browser
Input HCL
Output
Formatted HCL will appear here…

Frequently Asked Questions

What is HCL and why does formatting matter?▼

HCL (HashiCorp Configuration Language) is the declarative language used by Terraform to define infrastructure. Consistent formatting makes diffs smaller in code review, reduces merge conflicts, and makes large configs easier to navigate. The official terraform fmt command enforces a canonical style, and this tool applies the same rules in your browser.

What does terraform fmt actually do?▼

terraform fmt reformats HCL files to canonical style: 2-space indentation, aligned = signs within blocks, normalized blank lines, and consistent brace placement. It does not change logic — only whitespace and alignment. You should run it as a pre-commit hook or in CI to keep your codebase consistent.

Should I sort attributes alphabetically?▼

Alphabetical sorting is optional and depends on team preference. It makes it easier to find attributes in large blocks and reduces the chance of duplicate keys, but it can make logically-related attributes (like ingress/egress rules) feel disconnected. This formatter lets you toggle it on or off.

What Terraform block types are supported?▼

This formatter recognises terraform, provider, resource, data, variable, output, locals, module, and moved blocks. Each block is parsed individually so indentation and alignment are correctly scoped to their own block level.

What does the 'Extract Variables' button do?▼

It scans your HCL for every var.xxx reference and generates a variables.tf skeleton with an empty variable block for each unique variable name. This is handy when you've written a module and need to declare all its input variables quickly.

What are the deprecated 0.11-style patterns this tool detects?▼

Terraform 0.12 introduced first-class expressions. Common 0.11 patterns that still work but are discouraged include: string-wrapping references like "${var.name}" (should be just var.name), and list() / map() constructor functions that were replaced by literal syntax. This tool flags them so you can modernise your configs.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →