A command-line tool that converts HCL (HashiCorp Configuration Language) files to JSON format.
hcl2json is a command-line tool that converts HCL (HashiCorp Configuration Language) files to JSON format. It solves the problem of processing HCL configurations, such as those used in Terraform, with non-Go applications and scripts that may not natively support HCL parsing.
Developers and DevOps engineers working with HashiCorp tools like Terraform who need to integrate HCL configurations into JSON-based workflows, pipelines, or other programming environments.
It provides a straightforward, specification-free conversion for common use cases, with options for advanced formatting and simplification, and is available as a lightweight CLI tool, Docker image, or via package managers.
Convert hcl2 to json
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Converts HCL to JSON using heuristics without needing a schema, making it easy for common cases like basic Terraform configs, as highlighted in the alternatives section.
Accepts input from files or standard input, enabling seamless use in scripts and automated workflows, as demonstrated in the usage examples with stdin.
Available as a Docker image on DockerHub, allowing consistent execution across different environments without local installation, mentioned in the Docker support section.
The -simplify flag evaluates static expressions that don't use variables or unknown functions, simplifying HCL for analysis, as noted in the key features.
The README admits conversion may not be exactly equivalent in corner cases, especially for applications using static analysis, which can lead to unreliable output.
Relies on heuristics that can fail for complex or unconventional HCL structures, unlike specification-based tools like hcldec that offer more precision.
Expression simplification only works for static parts without variables or unknown functions, leaving dynamic expressions unconverted and limiting utility in variable-heavy configs.