hcl2json
« Back to VersTracker
Description:
Convert HCL2 to JSON
Type: Formula  |  Tracked Since: Dec 28, 2025
Links: Homepage  |  formulae.brew.sh
Category: Developer tools
Tags: hcl json terraform cli converter devops
Install: brew install hcl2json
About:
hcl2json is a command-line utility that parses HashiCorp Configuration Language (HCL2) files and converts them into equivalent JSON structures. It preserves the logic and configuration of HCL while providing the machine-readable format of JSON, making it ideal for programmatic processing. This tool is particularly useful for developers working with Terraform or other HCL-based systems who need to export or analyze configurations in JSON.
Key Features:
  • Preserves HCL structure and semantics in JSON output
  • Handles complex HCL2 features like functions, variables, and references
  • Fast parsing with minimal dependencies
  • Supports both pretty-printed and compact JSON output
Use Cases:
  • Converting Terraform configurations to JSON for external tooling
  • Parsing HCL configuration files in CI/CD pipelines
  • Analyzing HCL configurations programmatically
  • Generating JSON documentation from HCL source files
Alternatives:
  • hclfmt – hclfmt only formats HCL code, while hcl2json converts it to a different data format
  • jq – jq processes JSON but cannot parse HCL directly; requires hcl2json as a preprocessing step
Version History
Detected Version Rev Change Commit
Aug 26, 2025 11:02am 0 VERSION_BUMP 59287b2e
Dec 21, 2024 7:59am 0 VERSION_BUMP d90d2f74