Terraform/HCL Formatter
Format and validate Terraform/HCL configuration files with proper indentation, aligned equals signs, and normalized spacing
HCL Input
Formatted Output
Formatted output will appear here
Terraform/HCL Formatter
Format and validate Terraform/HCL configuration files with proper indentation, aligned equals signs, and normalized spacing
Features
- Proper 2-space indentation for nested blocks
- Aligns equals signs within the same block for readability
- Normalizes spacing around operators and braces
- Validates basic HCL syntax including matching braces and quotes
- Shows precise error location for invalid configuration
- Sample AWS Terraform config with EC2 and S3 resources
How to use
- Paste your Terraform or HCL code into the input area or click Load Sample
- Click the Format HCL button to process your configuration
- Review the formatted output with aligned equals signs and proper indentation
Tips & Best Practices
- All processing happens in your browser — no data is sent to any server.
- Use the copy button to quickly transfer results to your clipboard.
- The tool works offline once loaded — no internet connection required for processing.
- Check the FAQ section below for answers to common questions.
- Share this tool with colleagues using the social sharing buttons.
FAQ
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.