YAML to HCL Converter - Convert YAML Configuration to Terraform HCL
Convert YAML configuration files to Terraform HCL in your browser.
How to Convert YAML to HCL
Input Your YAML Configuration
Paste your YAML configuration or upload a .yaml/.yml file. Anything YAML can hold works, from a hand-written Terraform-shaped config to a values file you want to reuse.
Automatic Conversion to HCL
The Terraform HCL appears as you type. Keys like resource, variable and output become labeled blocks and everything else plain attributes. If something had to change, such as 00501 being written as a string, a note above the output says so, and a YAML mistake is reported with its line and column.
Download or Copy HCL
Copy the converted HCL to clipboard or download as .tf file for your Terraform projects.
Frequently Asked Questions
Why convert YAML to HCL?
Terraform reads HCL, so a config you already keep in YAML (or a values file from another tool) has to be rewritten before Terraform can use it. Doing it by hand means re-quoting every string and turning nesting into blocks; the converter does that part for you.
How does the YAML become Terraform blocks?
Top-level keys that Terraform knows as block types (resource, data, variable, output, module, provider, locals, terraform) become labeled blocks, so resource: aws_instance: web: ... turns into resource "aws_instance" "web" { ... }. Lifecycle, provisioner and the other blocks Terraform itself defines stay blocks too. Every other key is written as a plain name = value attribute, and nested maps as name = { ... }.
Will my numbers and strings come through unchanged?
Yes. Numbers are written the way you typed them, so 8901240544102066246 keeps every digit and 14.50 keeps its zero. A value with leading zeros such as 00501 is written as a string, because HCL would read it as 501. Quotes, backslashes and line breaks in strings are escaped, and ${ is written as $${ so Terraform does not treat your text as interpolation.
Can I convert a Kubernetes manifest into Terraform?
You get the manifest's data as valid HCL, but not a kubernetes_deployment or similar resource: the converter doesn't know provider schemas. Paste the output inside the right resource block yourself and adjust names to what the Kubernetes provider expects. Plain strings also stay quoted, so a value like aws_instance.web.id comes out as text; remove the quotes where you meant a reference.
What happens with several YAML documents or a top-level list?
An HCL file has one body of attributes, so several documents separated by --- are written as a list under documents, a top-level list under items, and a single value under value. A note above the output says when this happened.
Is my YAML sent anywhere?
No. The conversion runs in your browser, so the YAML you paste or upload never leaves your computer.
Going the other way? Use the HCL to YAML converter, and check the result with the HCL Validator.
Related Tools
HCL to JSON
Convert HashiCorp Configuration Language (Terraform) to JSON format
JSON to HCL
Convert JSON to HashiCorp Configuration Language for Terraform
HCL Formatter
Format and beautify HCL/Terraform configuration files with proper indentation
HCL Validator
Validate HCL/Terraform syntax and structure with error detection
HCL Fixer
Fix broken HCL/Terraform files automatically, repair syntax errors, missing braces, and malformed blocks
HCL to YAML
Convert Terraform HCL configuration to YAML format