Convert YAML to HCL Online
Convert YAML to HashiCorp HCL online for Terraform variable files, terraform.tfvars workflows, infrastructure as code setups, and developer tooling.
How to use YAML to HCL Converter
Paste content into the yaml input panel.
Run the converter to generate the target format instantly.
Copy or download the result once it looks right.
What this tool helps you do
Paste, convert, and copy results quickly
Useful for APIs, configuration files, and structured text
Sample input is built in for quick testing
Download the converted output as a file
Why this helps in text and data workflows
Converting a Kubernetes YAML config or Helm values file into HCL to review or adapt it for a Terraform resource.
Translating a YAML-based CI/CD variable definition into HCL format for a terraform.tfvars file.
Reformatting a YAML config block into HCL so it can be pasted directly into a Terraform module.
Converting a YAML data structure from an infrastructure-as-code tool into HCL for use in Packer or another HashiCorp tool.
Common problems and fixes
The YAML has anchors and aliases and the HCL output is wrong.
YAML anchors (&) and aliases (*) are resolved before conversion — the converter expands them into their full values. If the resolved output looks unexpected, check that the anchor definitions in the source YAML are correct.
Null values in the YAML are missing from the HCL output.
HCL has no null type. YAML null values (null, ~, or empty) are omitted during conversion. Replace them with a meaningful default value in the source YAML if they need to appear in the HCL output.
Boolean values like yes or on in YAML are converting unexpectedly.
YAML treats yes, no, on, off, true, and false all as booleans. The converter maps them to HCL true or false. If you intended them as strings, quote them in the source YAML before converting.
Related tools
Related Guides
Frequently asked questions
How do I convert YAML to HCL?
Paste your YAML into the input box, run the converter, and copy or download the generated HCL output.
Can I use this YAML to HCL converter for terraform.tfvars values?
Yes. It is well suited to YAML objects, lists, and values that need readable Terraform-style HCL assignments for terraform.tfvars workflows.
Is this YAML to HCL converter free?
Yes. It is free to use on the site.
Why would I convert YAML to HCL?
If your infrastructure configuration is defined in YAML — for example in Kubernetes manifests or Helm charts — and you need to adapt parts of it for Terraform or another HashiCorp tool, converting to HCL saves time reformatting by hand.
What is the main difference between YAML and HCL?
YAML is a general-purpose data serialisation format used across many tools. HCL is a configuration language designed specifically for HashiCorp tools like Terraform and Packer. HCL uses block syntax and assignment expressions rather than YAML's indentation-based structure.
Can I convert HCL back to YAML?
Not directly with a single tool here, but you can convert HCL to JSON with the HCL to JSON converter, then convert JSON to YAML with the JSON to YAML converter.