skillfed

pyhocon

HOCON parser for Python

pyhocon v0.3.63 4.9M downloads/30d#2,207 on PyPI533
Permissive license Apache License 2.0 Active released

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 pyhocon

uv

uv add pyhocon

poetry

poetry add pyhocon

Installing 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

License :: OSI Approved :: Apache Software LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules

Tags

hocon parser pythonconfig file parsingnested configuration managementtypesafe config pythonenvironment variable substitution configconfiguration file format conversionhocon to json converter
config-managementhocondata-serialization

More Python Modules packages