Terraform/HCL Formatter
Format and validate Terraform/HCL configuration files with proper indentation, aligned equals signs, and normalized spacing
HCL Entrada
Saída Formatada
Formatted saída will appear here
Terraform/HCL Formatter
Format and validate Terraform/HCL configuration files with proper indentation, aligned equals signs, and normalized spacing
Recursos
- Indent HCL blocks consistently, align `=` within block scopes
- Validate brace / quote / heredoc balance
- NOT a full HCL AST parser — uses regex + brace counting. Real Terraform syntax (dynamic blocks, complex interpolations, for_each) may produce imperfect output
- For production formatting use `terraform fmt` (the official CLI command)
- Runs entirely in your browser
Como usar
- Cole seu Terraform ou HCL código em o entrada area ou clique Load Sample
- Clique o Formato HCL botão para process seu configuração
- Review o formatted saída com aligned equals signs e proper indentation
Dicas e Melhores Práticas
- `terraform fmt -recursive` from the official CLI is the canonical formatter — this tool is for one-off snippets without leaving the browser.
- Heredoc strings (<<EOF … EOF) are detected and preserved as-is.
- Complex interpolations like `"${var.x ? a : b}"` may not re-format perfectly — verify after pasting.
- For the dynamic block syntax (introduced in Terraform 0.12), the formatter handles basic cases but doesn't deeply understand the iterator scope.
- Validation finds unbalanced braces / quotes; for semantic validation (resource attribute spelling) use `terraform validate`.
Perguntas Frequentes
What is Terraform HCL?
HCL (HashiCorp Configuration Language) is the configuration language used by Terraform to define infrastructure as code. It uses a human-readable syntax with blocks, arguments, and expressions to describe cloud resources.
How does the formatter align equals signs?
The formatter groups consecutive assignment lines within the same block and pads the keys so that all equals signs line up vertically. This makes the configuration much easier to scan and review during code reviews.
What validation checks does it perform?
It checks for matching opening and closing braces, unterminated string literals, and basic structural issues. It reports the exact line and column of each error so you can quickly locate the problem.
Is my Terraform code sent to any server?
No, all formatting and validation happens entirely in your browser. Your infrastructure code never leaves your device, ensuring complete privacy and security for sensitive configurations.
Does it handle heredoc syntax?
Yes, the formatter recognizes heredoc blocks (<<EOF / <<-EOF) and preserves their contents without reformatting, since heredoc content is typically meant to retain its original formatting.
What indentation style does it use?
The formatter uses 2-space indentation, which is the standard recommended by HashiCorp for Terraform configuration files. This matches the output of the official terraform fmt command.