hogql-parser
HogQL parser for internal PostHog use
What it is and what it does
HogQL Parser is a native C++ extension for Python that parses HogQL query expressions, SELECT statements, and Hog programs into abstract syntax trees. It wraps an ANTLR4-based parser shared with a WebAssembly version for JavaScript. The package is designed for internal PostHog use and supports Python 3.10 through 3.13 on macOS and Linux platforms.
The parser accepts HogQL syntax—a SQL-like query language—and produces structured ASTs that can be consumed by downstream tools. It has no runtime dependencies and installs via prebuilt wheels for supported architectures, though Windows is not supported. The package is actively maintained and has seen recent releases.
Use it for:
- Parse HogQL expressions in PostHog analytics pipelines to validate or transform user queries
- Build development tools or IDE plugins that need to understand HogQL syntax and structure
- Integrate HogQL query parsing into backend services running on Linux or macOS infrastructure
- Generate ASTs for query optimization or analysis in analytics platforms
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses HogQL query expressions and Hog programs into abstract syntax trees, available as a native C++ extension for Python on macOS and Linux.
Yes, if you are building on PostHog or need to parse HogQL syntax on macOS or Linux. The package is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and ranks in the top 5000 PyPI packages by downloads. Install friction is moderate due to platform and architecture constraints—Windows users cannot use it. Verify that the Python API matches your needs before committing.
Install
hogql-parser on PyPI
pip
pip install hogql-parseruv
uv add hogql-parserpoetry
poetry add hogql-parserInstalling hogql-parser
Before you install
Medium install friction due to platform-specific prebuilt wheels; requires macOS or Linux with x86_64 or arm64 architecture. Active maintenance with recent releases and no known vulnerabilities.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install hogql_parser
from hogql_parser import parse_expr
ast = parse_expr('1 + 2')
print(ast)
Requires macOS or Linux; Windows is not supported. Python 3.10 or later required.
Verify before relying
- Exact API surface and return types for Python parse functions (description shows npm API but Python equivalents not detailed)
- Whether parse functions return JSON strings or native Python objects in the Python package
- Error handling behavior in Python (whether errors are raised or returned as objects like the npm version)
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 15 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,137,173/month — #3,263 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: hogql_parser-1.3.83-cp310-cp310-macosx_14_0_arm64.whl; hogql_parser-1.3.83-cp310-cp310-macosx_15_0_x86_64.whl; hogql_parser-1.3.83-cp310-cp310-manylinux_2_28_aarch64.whl; hogql_parser-1.3.83-cp310-cp310-manylinux_2_28_x86_64.whl; hogql_parser-1.3.83-cp311-cp311-macosx_14_0_arm64.whl; hogql_parser-1.3.83-cp311-cp311-macosx_15_0_x86_64.whl; hogql_parser-1.3.83-cp311-cp311-manylinux_2_28_aarch64.whl; hogql_parser-1.3.83-cp311-cp311-manylinux_2_28_x86_64.whl; hogql_parser-1.3.83-cp312-cp312-macosx_14_0_arm64.whl; hogql_parser-1.3.83-cp312-cp312-macosx_15_0_x86_64.whl; hogql_parser-1.3.83-cp312-cp312-manylinux_2_28_aarch64.whl; hogql_parser-1.3.83-cp312-cp312-manylinux_2_28_x86_64.whl; hogql_parser-1.3.83-cp313-cp313-macosx_14_0_arm64.whl; hogql_parser-1.3.83-cp313-cp313-macosx_15_0_x86_64.whl; hogql_parser-1.3.83-cp313-cp313-manylinux_2_28_aarch64.whl; hogql_parser-1.3.83-cp313-cp313-manylinux_2_28_x86_64.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
hogql-parser-rsParses HogQL query expressions into JSON AST…
permissive · top 5,000 on PyPI
fugue-sql-antlrParses Fugue SQL dialect into an abstract…
permissive · top 5,000 on PyPI
tree-sitter-rubyProvides a Ruby language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-pythonProvides a Python grammar for tree-sitter,…
permissive · top 5,000 on PyPI
openqasm3Provides a reference abstract syntax tree (AST)…
permissive · top 15,000 on PyPI
tree-sitter-phpProvides a PHP language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-goProvides a Go language grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-javaProvides a Java language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-swiftProvides a tree-sitter grammar for parsing…
permissive · top 5,000 on PyPI
tree-sitter-jsonProvides a JSON grammar parser for tree-sitter,…
permissive · top 5,000 on PyPI