Convert JSON to HCL Online
Convert JSON to HashiCorp HCL online for Terraform variable files, terraform.tfvars workflows, infrastructure as code setups, and developer tooling.
How to use JSON to HCL Converter
Paste content into the json 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 JSON object of variable values into HCL format to paste into a terraform.tfvars file.
Translating a JSON config block from an API response into HCL syntax for use in a Terraform resource definition.
Reformatting a JSON-based infrastructure definition into HCL for a Terraform module that expects .tf file input.
Generating a readable HCL representation of a JSON data structure for review or documentation purposes.
Common problems and fixes
The HCL output has quoted keys but my Terraform file uses bare keys.
The converter quotes keys that contain special characters or would otherwise be ambiguous in HCL. For simple alphanumeric keys the output uses bare identifiers. If you need all bare keys, make sure your JSON key names use only letters, digits, underscores, and hyphens.
Null values in the JSON are missing from the HCL output.
HCL does not have a null type. JSON null values are omitted during conversion. Remove or replace nulls with a placeholder value in the source JSON if the field must appear in the HCL output.
Nested JSON objects are not converting to the block syntax I expected.
Nested JSON objects become nested assignment blocks in HCL, not named blocks with labels. If you need labelled blocks like resource or variable, structure the input JSON to include those label levels explicitly.
Related tools
Related Guides
Frequently asked questions
How do I convert JSON to HCL?
Paste your JSON into the input box, run the converter, and copy or download the generated HCL output.
Can I use this JSON to HCL converter for terraform.tfvars values?
Yes. It is well suited to JSON objects, lists, and values that need readable Terraform-style HCL assignments for terraform.tfvars workflows.
Is this JSON to HCL converter free?
Yes. It is free to use on the site.
What is a terraform.tfvars file?
A terraform.tfvars file is a plain HCL file that supplies values for Terraform input variables. It uses simple key = value assignments and is loaded automatically by Terraform when present in the working directory.
Does Terraform also accept JSON instead of HCL?
Yes. Terraform accepts JSON natively — files ending in .tf.json are treated as JSON configuration. Converting to HCL is useful when you prefer a more readable format or are working in a codebase that uses .tf files.
Can I convert HCL back to JSON?
Yes. Use the HCL to JSON converter to go in the other direction.