Loading JSON to HCL Converter...
Please wait a moment

How to Convert JSON to HCL

Convert JSON to HashiCorp Configuration Language (HCL) for Terraform and other HashiCorp tools.

Step 1

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"
        }
      }
    }
  }
}
Step 2

Automatic Conversion

The converter transforms JSON into readable HCL syntax automatically. Object structures become blocks, and arrays are properly formatted for HashiCorp Terraform compatibility.

Object blocks: JSON objects are converted into HCL block syntax
Array handling: Arrays are properly formatted for Terraform compatibility
String values: String values are preserved with proper HCL quoting
Nested structures: Complex nested JSON configs become nested HCL blocks
Step 3

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"
  }
}
Step 4

Use in Your Project

Integrate the generated HCL into your Terraform or OpenTofu infrastructure as code project.

Copy to clipboard: For immediate use in your Terraform files
Download .hcl file: For direct integration into your IaC project
Use with Terraform: Compatible with Terraform and OpenTofu
Add comments: Enhance readability with HCL inline comments

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.