JSON to HCL Converter - Convert to Terraform Format Online
Free JSON to HashiCorp Configuration Language Converter
How to Convert JSON to HCL
Convert JSON to HashiCorp Configuration Language (HCL) for Terraform and other HashiCorp tools.
Paste JSON Data
Paste your JSON configuration or upload a .json file. Works with Terraform JSON configs and standard JSON structures.
Example: Try This JSON Data
Copy and paste this JSON example to see how it converts to HCL:
{ "resource": { "aws_instance": { "web": { "ami": "ami-0c55b159cbfafe1f0", "instance_type": "t2.micro", "tags": { "Name": "web-server", "Environment": "production" } } } } }
Automatic Conversion
The converter transforms JSON into readable HCL syntax automatically. Object structures become blocks, and arrays are properly formatted for HashiCorp Terraform compatibility.
Download HCL File
Copy the HCL output or download as a .hcl file for use in your infrastructure as code projects.
HCL Output
Your JSON becomes this HCL configuration:
resource "aws_instance" "web" { ami = "ami-0c55b159cbfafe1f0" instance_type = "t2.micro" tags { Name = "web-server" Environment = "production" } }
Use in Your Project
Integrate the generated HCL into your Terraform or OpenTofu infrastructure as code project.
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?
Yes! The converter generates valid HCL syntax compatible with Terraform. However, you may want to add comments and refine the structure for better readability.
Can I convert complex JSON structures?
Yes, the converter handles nested objects and arrays. Complex JSON configurations are converted to properly structured HCL blocks.
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.
Is this tool free?
Yes, completely free with unlimited conversions. No registration required.
Related Tools
HCL to JSON
Convert HashiCorp Configuration Language (Terraform) to JSON format
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
YAML to HCL
Convert YAML configuration to Terraform HCL format