Loading HCL to YAML Converter...
Please wait a moment

How to Convert HCL to YAML

Step 1

Paste or upload your HCL

Paste Terraform or other HCL into the left editor, or upload a .tf, .hcl, .tfvars or .nomad file of up to 10 MB. The Sample button loads a small Terraform file if you just want to see how it works.

Anything written in HCL syntax works, not only Terraform: Nomad jobs, Packer templates and Vault configs read the same way.

Step 2

Check the YAML

The YAML appears on the right a moment after you stop typing. If the HCL has a mistake, such as a missing brace or an unclosed string, you get the line and column instead of half-converted output.

The output is standard YAML with two-space indentation, which older YAML 1.1 readers such as PyYAML and newer YAML 1.2 readers both accept.

Step 3

Copy or download it

Copy the YAML to your clipboard or download it as converted.yaml. Both always match the HCL that is in the editor at that moment.

Frequently Asked Questions

Why would I convert HCL to YAML?

Usually to reuse Terraform settings somewhere that speaks YAML: variable values for a CI pipeline, Ansible vars, a Helm values file, or just a quick readable dump of a .tfvars file to compare with a Kubernetes manifest. The conversion is about the data in the file, not about running Terraform.

How do blocks and labels show up in the YAML?

The same way Terraform's own JSON syntax (.tf.json) spells them. A block like resource "aws_instance" "web" becomes resource → aws_instance → web, and the block body is a list item under it. Two ebs blocks in one resource give a list with two entries, so nothing is merged or lost.

Are references like var.region worked out?

No. Nothing is evaluated: references, function calls and "${…}" templates are written as "${…}" text, for example var.region becomes "${var.region}". A literal $${ in your HCL stays escaped, so it is not mistaken for a template later.

Will my numbers and strings change?

Values come through as they are. A long ID such as 8901240544102066246 keeps every digit, and a plain decimal like 14.50 keeps its trailing zero. Strings that a YAML reader could take for something else, such as yes, no, on, null, 00501 or 2024-01-15, are quoted so they stay strings in both older YAML 1.1 readers like PyYAML and newer YAML 1.2 ones. Heredocs become | blocks with the same text. One thing does change: a number written with an exponent, like 1e3, comes out as 1000.

What happens to comments?

They are left out. The HCL parser reads values, not comments, so the YAML only carries the data. The page tells you when your file had comments, so you know to copy over any that matter.

Is my configuration uploaded anywhere?

No. The conversion runs in your browser, the HCL is not sent to our server, and nothing is kept: reloading the page gives you an empty editor. Terraform files often hold account IDs and other details, so that matters.

Going the other way? The YAML to HCL converter turns YAML back into HCL. To tidy or check a Terraform file first, try the HCL Formatter or the HCL Validator, and if you need JSON rather than YAML, HCL to JSON gives you the same data as JSON.