--- id: tree-sitter-hcl version: "1.2.0" license: Apache-2.0 license_treatment: permissive maintenance: aging --- # tree-sitter-hcl — HCL and terraform grammar for tree-sitter License: permissive · Maintenance: aging · Downloads: 132.1K/mo ## What it is and what it does tree-sitter-hcl is a tree-sitter grammar binding for parsing HCL and Terraform configuration files in Python. It wraps the tree-sitter incremental parsing engine, which builds a concrete syntax tree that can be queried and traversed programmatically. The package ships as precompiled wheels for most platforms, eliminating the need to build the grammar from source in typical use. The parser is designed for developers who need to analyze, transform, or validate HCL configurations programmatically—common in infrastructure-as-code tooling, linters, and Terraform-related utilities. Testing against a real-world corpus of HCL files achieved 100% parse success rate across all files tested. Use it for: - Build a Terraform linter or static analyzer that inspects HCL syntax and structure. - Extract metadata from Terraform configurations such as resource names and variable definitions. - Implement IDE features like syntax highlighting and code completion for HCL editors. - Validate HCL configuration files before deployment in CI/CD pipelines. - Migrate or refactor Terraform code by programmatically rewriting the syntax tree. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides a tree-sitter parser grammar for HCL and Terraform, enabling incremental parsing and syntax analysis of HCL configuration files. Yes, if you need to parse or analyze HCL/Terraform files programmatically. The package is stable with no known vulnerabilities and permissively licensed. Install friction is moderate due to compilation, but prebuilt wheels are available for common platforms. The aging maintenance status is acceptable for a grammar binding—updates are typically infrequent unless the underlying HCL specification changes. ## Install pip install tree-sitter-hcl uv add tree-sitter-hcl poetry add tree-sitter-hcl ## Installing tree-sitter-hcl Before you install: Medium install friction due to compiled wheels; prebuilt binaries are available for common platforms (x86_64, ARM64, macOS, Linux, Windows). Repository remains active and unarchived, though last release was 424 days ago. License in practice: Licensed under Apache-2.0 (permissive), allowing free use, modification, and distribution with minimal restrictions; suitable for both open-source and commercial projects. Quickstart: pip install tree-sitter-hcl from tree_sitter_hcl import language parser = language.parser() tree = parser.parse(b'resource "aws_instance" { }') Requires Python >=3.10; compiled wheels provided for common platforms but may require a C compiler on unsupported architectures. Verify before relying: - Whether the parser handles all HCL2 syntax variants beyond the core language specification. - Performance characteristics and memory overhead for parsing large configurations. - Compatibility with specific tree-sitter versions or ecosystem tooling beyond Python >=3.10. ## Package facts - License: Apache-2.0 (permissive) - Python support: supports_current - Install friction: medium - Maintenance: aging - Downloads: 132.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags HCL parser, tree-sitter grammar, terraform parsing, incremental parsing, HCL syntax analysis, configuration language parser, tree-sitter HCL, terraform, parsing, syntax-tree [View on SkillFed](https://skillfed.io/packages/tree-sitter-hcl) · [View on PyPI](https://pypi.org/project/tree-sitter-hcl/)