skillfed

pyhcl

HCL configuration parser for python

pyhcl v0.4.5 9.8M downloads/30d#1,501 on PyPI341
Copyleft license AGING released

What it is and what it does

pyhcl is a Python parser for HCL (HashiCorp Configuration Language), the configuration syntax used by Terraform and other HashiCorp tools. It reads HCL files and converts them into Python dictionaries, mirroring the interface of Python's built-in json module with load, loads, and dumps functions. The parser is based on the original Go implementation and aims for compatibility with it.

The package is designed for HCL1 syntax and has been modified to work with Terraform 0.12, but does not support HCL2, which is used by modern Terraform versions. It includes a command-line tool (hcltool) to convert HCL files to JSON. The output structure is a plain Python dictionary with no built-in schema validation; users are expected to validate the result separately using external tools if needed.

Use it for:

  • Parse Terraform configuration files (0.12 and earlier) for programmatic inspection or transformation.
  • Convert HCL configuration files to JSON format using the included hcltool command-line utility.
  • Load HashiCorp tool configuration files into Python applications for dynamic configuration management.
  • Integrate HCL parsing into legacy systems that predate HCL2 and modern Terraform.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Parses HCL (HashiCorp Configuration Language) files into Python dictionaries, providing load/loads/dumps functions similar to the json module.

Yes, if you need to parse HCL1 or Terraform 0.12 configurations. The package is stable, has no dependencies, and installs easily. However, do not use it for modern Terraform (which requires HCL2 support); maintenance is aging with the last release in 2023-09-01, so expect limited support for new Python versions or edge cases. The copyleft license (MPL 2.0) requires disclosure of modifications if you redistribute derived work.

Install

pyhcl on PyPI

pip

pip install pyhcl

uv

uv add pyhcl

poetry

poetry add pyhcl

Installing pyhcl

Before you install

Low install friction with no runtime dependencies. Maintenance is aging—last release was 2023-09-01, though the repository remains active with a recent commit in 2026-01-20.

License in practice

Licensed under Mozilla Public License 2.0 (MPL 2.0), a copyleft license requiring derivative works to disclose modifications and maintain the same license.

Quickstart

pip install pyhcl

import pyhcl

with open('file.hcl', 'r') as fp:
    obj = pyhcl.load(fp)

Does not support HCL2 syntax used by modern Terraform; designed for HCL1 and Terraform 0.12 and earlier.

Verify before relying

  • Whether the package works reliably with current Python versions beyond those listed in classifiers.
  • Whether the Terraform 0.12 compatibility mentioned in the description covers all real-world use cases or only partial syntax.
  • Current maintenance status and likelihood of updates for edge cases or new Python versions.

Package facts

License not declared (copyleft)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 1,078 days since the last release
Last repo commit
First released
Downloads 9,784,913/month — #1,501 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pyhcl-0.4.5-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)Operating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Topic :: Text Processing

Tags

HCL parser pythonhashicorp configuration languageparse terraform confighcl to json converterconfiguration file parsinghcl syntax parser
configuration-parsingterraform

More Text Processing packages