HCL Formatter
Format and beautify HCL (HashiCorp Configuration Language) and Terraform files online. Fix indentation and normalize HCL syntax.
Input
Output
What is HCL?
HCL (HashiCorp Configuration Language) is a configuration language created by HashiCorp and used primarily in Terraform for defining infrastructure as code. It uses blocks with curly braces and supports attributes, nested blocks, expressions, and comments.
The HCL Formatter fixes indentation using 2-space indent levels, normalizes block structure, and cleans up whitespace — helping teams maintain consistent Terraform and HCL codebases. The HCL source is open on GitHub, and you can browse available providers and modules on the Terraform Registry.
How to Use
Paste your HCL content
Paste your Terraform or HCL file content into the left editor, or click Upload to load a .tf or .hcl file.
Instant formatting
The formatter fixes indentation (2 spaces per level), normalizes block structure, and removes trailing whitespace.
Copy or download
Use the Copy button to copy the result, or Download to save it as a .tf file.
Formatting Example
Example: Terraform resource block
Unformatted HCL:
resource "aws_instance" "web" {
ami="ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
tags={Name="web-server",Env="prod"}
}Formatted output:
resource "aws_instance" "web" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
tags = {
Name = "web-server"
Env = "prod"
}
}Frequently Asked Questions
What is the difference between HCL and Terraform?
Terraform is the infrastructure-as-code tool; HCL is the configuration language it uses. HCL is also used by other HashiCorp tools like Packer, Vault, and Consul.
Does this replace terraform fmt?
This is a quick online formatter for reviewing and cleaning HCL. For production use, terraform fmt is the official formatter and should be used in your CI/CD pipeline. The HCL Style Guide covers the full formatting conventions.
Can I format Packer or Vault HCL files?
Yes. The formatter handles standard HCL syntax used by all HashiCorp tools.
Can I use this to clean up Terraform modules or shared config files?
Absolutely. Terraform modules use the same HCL syntax as root configurations. Just paste the module file content and the formatter will fix indentation and normalize the block structure — great for tidying up shared code before committing.