--- id: bc-python-hcl2 version: "0.4.3" license: MIT license_treatment: permissive maintenance: aging --- # bc-python-hcl2 — A parser for HCL2 License: permissive · Maintenance: aging · Downloads: 4.6M/mo ## What it is and what it does bc-python-hcl2 is a HCL2 parser for Python that converts HashiCorp Configuration Language v2 files into native Python dictionaries. It uses Lark, a parsing toolkit, to handle the HCL2 grammar and is commonly used to programmatically read and process Terraform configuration files. The package is a maintained fork of the original python-hcl2 project, officially supported by Bridgecrew, and supports Python 3.8 through 3.12. The parser is designed specifically for HCL2 and does not support the older HCL v1 syntax. It provides a simple API—typically just calling `hcl2.load()` on an open file—making it straightforward to integrate into tools that need to inspect or manipulate infrastructure-as-code configurations programmatically. Use it for: - Parse Terraform .tf files to extract resource definitions and configuration values for analysis or validation - Build tooling that reads HCL2 configs to generate documentation or reports about infrastructure - Integrate HCL2 parsing into policy-as-code or security scanning tools that inspect infrastructure definitions - Convert HCL2 configurations to other formats (JSON, YAML) for interoperability with non-Terraform tools ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Parses HCL2 configuration files (such as Terraform configs) into Python dictionaries using a Lark-based parser. Yes, if you need to parse HCL2 files programmatically. The package has low install friction, permissive licensing, and no known vulnerabilities. However, note that maintenance is aging (last release 396 days ago) and the project has minimal community activity (5 stars). It remains suitable for stable use cases but may not receive rapid updates for new HCL2 features or edge cases. ## Install pip install bc-python-hcl2 uv add bc-python-hcl2 poetry add bc-python-hcl2 ## Installing bc-python-hcl2 Before you install: Low install friction with only two runtime dependencies (lark and importlib-resources). Maintenance status is aging—last release was 396 days ago and the repo shows minimal activity (5 stars), though it remains actively maintained and not archived. License in practice: MIT license is permissive, allowing use in both open-source and commercial projects with minimal restrictions. Quickstart: pip install bc-python-hcl2 import hcl2 with open('foo.tf', 'r') as file: config = hcl2.load(file) Requires Python 3.8 or higher. Verify before relying: - Completeness of HCL2 spec coverage beyond basic parsing—which features or edge cases may not be fully supported - Performance characteristics when parsing large or deeply nested configuration files - Whether the fork divergence from upstream python-hcl2 introduces breaking changes for existing users ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 4.6M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags HCL2 parser Python, Terraform config parser, HCL parser library, parse HCL2 files, Terraform file parsing, HCL configuration parser, infrastructure as code parsing, hcl2-parser, terraform, infrastructure-as-code [View on SkillFed](https://skillfed.io/packages/bc-python-hcl2) · [View on PyPI](https://pypi.org/project/bc-python-hcl2/)