What is JSON to HCL Converter?
HCL (HashiCorp Configuration Language) is a human-readable configuration language used by Terraform, Vault, Consul, and other HashiCorp tools. This converter transforms JSON data into HCL syntax and vice versa, making it easy to work with Terraform configurations in either format.
How to Use
- Select the conversion direction using the toggle button (JSON → HCL or HCL → JSON)
- Paste your JSON or HCL content into the input area
- Click "Convert" to generate the output
- Copy the result or click "Load Sample" to try with example data
Why Use This Tool?
Tips & Best Practices
- Terraform supports both .tf (HCL) and .tf.json (JSON) files natively
- HCL supports comments (// and #) which JSON does not — comments are lost when converting HCL to JSON
- Complex HCL features like resource blocks with labels, dynamic blocks, and for_each may require manual adjustment after conversion
- When converting from JSON to HCL, nested objects become HCL map blocks
Frequently Asked Questions
What is HCL?
HCL (HashiCorp Configuration Language) is a configuration language built by HashiCorp. It is designed to be both human-readable and machine-friendly, making it ideal for infrastructure as code tools like Terraform.
Can Terraform use JSON instead of HCL?
Yes, Terraform supports JSON configuration files with the .tf.json extension. While HCL is recommended for human-written configs, JSON works well for machine-generated configurations.
Why convert JSON to HCL?
HCL is more readable and supports comments, making it easier to maintain. Converting JSON to HCL is useful when you have machine-generated configs that you want to edit by hand.
Is my data sent to a server?
No, all conversion happens entirely in your browser. Your Terraform configurations and JSON data never leave your device.