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

How to Convert HCL to JSON

Convert HashiCorp Configuration Language (HCL) from Terraform, Vault, and Consul to JSON format online for free.

Step 1

Paste HCL Configuration

Paste your HCL configuration from Terraform (.tf files), Vault, or Consul, or upload an .hcl file directly.

Example: Terraform HCL Configuration

Copy and paste this HCL example to see how it works:

resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"

  tags {
    Name        = "web-server"
    Environment = "production"
  }
}
Step 2

Automatic Conversion

The converter parses HCL syntax and converts it to equivalent JSON structure instantly. All resource blocks, variables, and nested configurations are preserved.

Resource blocks: All Terraform resource blocks are preserved in JSON output
Variables: Variable definitions are correctly mapped to JSON
Nested configurations: Nested HCL blocks become nested JSON objects
Step 3

Download or Copy JSON

Copy the converted JSON to your clipboard or download as a .json file for use in CI/CD pipelines, or configuration tools.

Copy to clipboard: One-click copy for immediate use
Download as .json file: Save for use in your project
CI/CD integration: Use in pipelines and automation scripts

What is HCL (HashiCorp Configuration Language)?

HCL (HashiCorp Configuration Language) is a configuration language created by HashiCorp for their infrastructure tools. It's designed to be both human-readable and machine-friendly, making it ideal for infrastructure as code.

HCL is used by Terraform for defining cloud infrastructure, Vault for security policies, and Consul for service configurations. While HCL is more readable than JSON, converting to JSON can be useful for programmatic processing or integration with tools that only accept JSON input.

Frequently Asked Questions

What is HCL used for?

HCL is the configuration language for HashiCorp tools like Terraform, Vault, and Consul. It's designed to be readable and easy to write for infrastructure as code.

Can Terraform use JSON instead of HCL?

Yes, Terraform supports JSON configuration files with .tf.json extension. While HCL is recommended, JSON works for machine-generated configs.

Why convert HCL to JSON?

JSON format allows processing with standard tools, integration with systems that don't support HCL, or programmatic manipulation of Terraform configurations.

Are HCL comments preserved?

No, JSON doesn't support comments. Comments are removed during conversion, which is a limitation of the JSON format.

Is this tool free?

Yes, completely free with unlimited conversions. No registration or file size limits.