pyhocon
HOCON parser for Python
What it is and what it does
pyhocon is a Python parser for HOCON, a configuration language that extends JSON with comments, variable substitution, includes, and a more human-friendly syntax. It reads HOCON files and returns them as nested Python dictionaries where values are automatically typed (strings, integers, booleans, lists, etc.) and can be accessed via dot-notation paths, dictionary keys, or typed getter methods like `get_string()` and `get_int()`.
The package handles HOCON's key features: environment variable substitution (e.g., `${HOME}`), file and URL includes with merge semantics, duration/period parsing, and conversion to JSON, YAML, or .properties formats via a command-line tool. It depends only on pyparsing for its parsing logic and has been actively maintained since 2015, supporting Python 3.7 through 3.12.
Use it for:
- Loading application configuration from HOCON files with automatic type inference and environment variable substitution
- Converting HOCON config files to JSON, YAML, or .properties formats for use in other tools or languages
- Building configuration hierarchies with includes and merging, where one config file can include and override settings from another
- Accessing nested configuration values using dot-notation paths without manually navigating nested dictionaries
- Parsing duration and period values from configuration files into Python timedelta objects
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses HOCON (Human-Optimized Config Object Notation) configuration files into Python dictionaries with automatic type inference, supporting nested access, environment variable substitution, and file includes.
Yes, if you need to parse HOCON configuration files in Python. The package is actively maintained, has no known vulnerabilities, and covers the HOCON spec well. Install friction is moderate due to source-only distribution, but this is a one-time setup cost. The permissive Apache 2.0 license poses no restrictions for most use cases.
Install
pyhocon on PyPI
pip
pip install pyhoconuv
uv add pyhoconpoetry
poetry add pyhoconInstalling pyhocon
Before you install
High install friction due to source distribution only (no wheels). The package is actively maintained with a recent release and no known vulnerabilities, but installation may require a C compiler or build tools on some systems.
License in practice
Licensed under Apache License 2.0 (permissive), allowing use in commercial and proprietary projects with minimal restrictions beyond attribution and liability disclaimers.
Quickstart
pip install pyhocon
from pyhocon import ConfigFactory
conf = ConfigFactory.parse_file('config.conf')
host = conf.get_string('databases.mysql.host')
port = conf['databases.mysql.port']
Installation from source; a C compiler or build tools may be required depending on your system.
Verify before relying
- Whether pyparsing version constraints exist or if any version of pyparsing works
- Performance characteristics when parsing large or deeply nested HOCON files
- Completeness of HOCON spec coverage beyond the documented differences (nanoseconds, months/years, m suffix)
Package facts
| License | Apache License 2.0 (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | 1 — pyparsing |
| Maintenance | actively maintained — 147 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,899,029/month — #2,207 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyhocon-0.3.63.tar.gz
Keywords: hocon, parser
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
HiYaPyCoLoads and merges multiple YAML configuration…
copyleft · top 15,000 on PyPI
hjsonParses and generates Hjson (a human-friendly…
permissive · top 5,000 on PyPI
hierarchical-confLoads configuration from YAML files organized…
unclear · top 15,000 on PyPI
pyaml-envParses YAML configuration files and resolves…
permissive · top 15,000 on PyPI
super-collectionsConverts nested JSON and YAML data into Python…
permissive · top 5,000 on PyPI
config-parserMerges configuration from YAML/JSON files,…
agpl · top 5,000 on PyPI
envyamlParses YAML configuration files with…
permissive · top 5,000 on PyPI
glomglom provides path-based access and declarative…
permissive · top 1,000 on PyPI
configProvides hierarchical configuration management…
permissive · top 5,000 on PyPI
jstylesonParses JSON strings that contain…
permissive · top 15,000 on PyPI