JSON to HCL Converter - Convert to Terraform Format Online
Convert JSON to HCL (HashiCorp Configuration Language) online for free.
How to Convert JSON to HCL
Paste JSON Data
Paste your JSON configuration or upload a .json file. Works with Terraform JSON configs and standard JSON structures.
Automatic Conversion
The HCL appears as you type. A Terraform JSON file turns into labeled blocks like resource "aws_instance" "web" { ... }; any other JSON becomes name = value attributes, with nested objects as { ... } and arrays as [ ... ]. The Layout menu above the output lets you pick either style yourself, which is handy for HashiCorp tools other than Terraform.
Download HCL File
Copy the HCL or download it. Terraform output saves as converted.tf, everything else as converted.hcl.
Why Convert JSON to HCL?
While Terraform accepts JSON, HCL is the preferred format for infrastructure code. HCL is more readable, supports comments, and provides better syntax for complex configurations.
Converting JSON to HCL makes your configurations easier to maintain, understand, and collaborate on. It's especially useful when working with machine-generated JSON configs that need to be human-readable.
Frequently Asked Questions
Why use HCL instead of JSON?
HCL is more human-readable and supports features like comments, expressions, and functions. It's the recommended format for Terraform and other HashiCorp tools.
Will the converted HCL work with Terraform?
Paste a .tf.json file and you get native Terraform: resource, data, variable, output, module, provider, locals and terraform blocks with their labels, plus lifecycle, provisioner and dynamic blocks inside resources. References such as depends_on, provider and variable types are written as expressions, not strings. The one thing it can't know is the provider schema, so a nested object inside a resource comes out as name = { ... }. If the provider wants a nested block there (root_block_device, ingress and the like), delete the = sign.
Can I convert complex JSON structures?
Yes. Nested objects become HCL objects and arrays become lists, so an array of objects is written as [{ ... }, { ... }] and reads back as the same data. Keys with spaces or dots are quoted, null stays null, and numbers like 8901240544102066246 or 14.50 are written exactly as they appear in your JSON.
Are JSON comments preserved?
JSON doesn't support comments, so there are no comments to preserve. However, you can add comments to the HCL output after conversion.
What happens to ${...} inside my strings?
In HCL a quoted string is a template, so ${...} would be evaluated. For ordinary JSON data the converter writes it as $${...} (and %{ as %%{), which reads back as the exact text you had. Terraform JSON is different: there ${var.name} is meant to be interpolated, so it is kept as it is, and a string that is only a reference, like "${var.ami}", is written as var.ami.
Is this tool free?
Yes, completely free with unlimited conversions. No registration required.