pyhcl
HCL configuration parser for python
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 pyhcluv
uv add pyhclpoetry
poetry add pyhclInstalling 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
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
python-hcl2Parses HCL2 configuration files (used by…
permissive · top 5,000 on PyPI
tfparsetfparse parses and evaluates Terraform HCL…
permissive · top 15,000 on PyPI
bc-python-hcl2Parses HCL2 configuration files (such as…
permissive · top 5,000 on PyPI
tree-sitter-hclProvides a tree-sitter parser grammar for HCL…
permissive · top 15,000 on PyPI
hvachvac is a Python client library for HashiCorp…
permissive · top 1,000 on PyPI
cdktfDefines cloud infrastructure using Python code…
copyleft · top 15,000 on PyPI
cdktf-cdktf-provider-awsProvides prebuilt Python bindings for the…
copyleft · top 15,000 on PyPI
hjsonParses and generates Hjson (a human-friendly…
permissive · top 5,000 on PyPI
libconfReads and writes configuration files in…
permissive · top 15,000 on PyPI
pytomlParses and writes TOML configuration files with…
permissive · top 15,000 on PyPI