Official Python YINI Parser

Parse YINI configuration files in Python.

The official Python parser for YINI is available as a release candidate for testing, examples, integrations, and feedback.

It lets Python applications, scripts, tools, and services load YINI configuration files as ordinary Python data structures.

Status: Release candidate

The parser is usable for testing and early integration, but the public API and edge-case behavior may still change before 1.0.0.


Install

pip install yini-parser

The package name on PyPI is:

yini-parser

The Python import name is:

import yini_parser

Quick example

Suppose you have this YINI file:

^ App
name = "Demo App"
version = 1.2
debug = false

    ^^ Server
    host = "localhost"
    port = 8080

Parse it in Python:

from yini_parser import load

config = load("config.yini")

print(config["App"]["name"])
print(config["App"]["Server"]["port"])

Output:

Demo App
8080

Parse from a string

Use loads(...) when the YINI input is already available as a string:

from yini_parser import loads

config = loads("""
^ App
name = "Demo App"
debug = false
""")

print(config["App"]["debug"])

Output:

False

What you get back

The parser returns normal Python values such as dictionaries, lists, strings, numbers, booleans, and None.

^ App
name = "Demo App"
features = ["search", "logs"]
debug = false

becomes:

{
    "App": {
        "name": "Demo App",
        "features": ["search", "logs"],
        "debug": False,
    }
}

Good fit for Python projects

The Python parser is useful for:

  • Application configuration.
  • Python scripts and tools.
  • Small services and internal utilities.
  • Testing YINI files in Python projects.
  • Trying YINI outside the TypeScript/JavaScript ecosystem.

Demo apps

The basic Python demo ↗ reads a small YINI configuration file and prints selected values. The medium Python demo ↗ shows nested sections, lists, inline objects, booleans, numbers, and strings.

For more examples in other languages, see YINI demo apps ↗.


If you want to work with YINI from the command line, see the YINI CLI page.

The CLI is useful for:

  • Validating YINI files from the CLI/terminal.
  • Converting YINI to JSON or JavaScript.
  • Inspecting configuration from the terminal.

If you want to try the parser or explore the project further, these links are a good place to continue.

Next steps

  • ➡️ YINI CLI

    Validate and convert YINI files from the terminal.

  • ➡️ YINI Parsers

    Compare the official parser options.