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.

This page indents by brace and bracket depth, two spaces a level, trims trailing spaces and squeezes runs of blank lines into one. Unlike terraform fmt, it does not line up the = signs inside a block, so run that before committing. The HCL source is open on GitHub, and you can browse available providers and modules on the Terraform Registry.

How to Use

1

Paste your HCL content

Copy a messy main.tf or module into the input pane, or open the .tf or .hcl file itself with Upload.

2

Formats as you type

Each resource, variable or locals block comes back indented two spaces per level, with comments kept at the level of their code.

3

Copy or download

Copy grabs the re-indented blocks. Download writes main.tf even if you started from variables.tf or outputs.tf, so rename it before it overwrites anything in your module folder.

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

Are HCL and Terraform the same thing?

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.

Related Tools