Skip to main content

natizon

natizon is a pure Python parser and serializer for ZON (Zig Object Notation). It converts ZON text directly into standard Python types, and serializes Python objects back into valid ZON — all without intermediate AST objects or wrapper layers. Its API is modeled after the standard library's json module, offering loads() and dumps() as the primary entry points.

Built on Lark, the library handles the full ZON grammar, including structs, arrays, enum literals, multiline strings, hexadecimal and float literals, and quoted identifiers.

API Overview

Function Signature Description
loads (zon_str, *, use_tuples=False, empty_mode=DICT) → dict Parse ZON string to Python dicts/lists.
dumps (obj, *, indent=None, sort_keys=False) → str Serialize Python object to ZON string.
validate_zon_serializable (obj) → None Validate an object is ZON-serializable; raises TypeError or ValueError.

Full type mapping reference →

Installation

pip install natizon

Or:

uv add natizon

Usage

natizon exposes loads() and dumps() functions that work similarly to the standard library's json module.

Parsing

import natizon

zon_data = r"""
.{
    .package_name = "network_tools",
    .version = "2.1.0",
    .supported_platforms = .{ .linux, .macos, .windows },
    .dependencies = .{
        .lib_a = .{ .url = "https://server.com/a.tar" },
        .lib_b = .{ .path = "../local_b" }
    }
}
"""

# Parses directly into standard Python dicts and lists
parsed_data = natizon.loads(zon_data)

print(parsed_data["package_name"])  # "network_tools"
print(parsed_data["supported_platforms"])  # ["linux", "macos", "windows"]

Serialization

You can serialize standard Python objects back into ZON text using dumps():

from enum import Enum
import natizon


class Difficulty(Enum):
    EASY = "easy"
    HARD = "hard"


game_config = {
    "title": "Neon Dash",
    "difficulty": Difficulty.HARD,
    "player_stats": {"level": 10, "xp": 1500},
}

zon_string = natizon.dumps(game_config, indent=2)
print(zon_string)

Output:

.{
  .title = "Neon Dash",
  .difficulty = .HARD,
  .player_stats = .{
    .level = 10,
    .xp = 1500,
  },
}

Advanced Usage

Validation

dumps() automatically validates your data before serialization. If you need to check whether an object is serializable without triggering the full serialization process, use validate_zon_serializable():

from natizon import validate_zon_serializable

user_settings = {
    "theme": "dark",
    "font_size": 14,
    "notifications": True,
}

# Raises TypeError if the object is not serializable,
# or ValueError if a circular reference is detected.
try:
    validate_zon_serializable(user_settings)
    print("Data is valid!")
except (TypeError, ValueError) as e:
    print(f"Validation failed: {e}")

Custom Serialization

Implement the ZonEncodable protocol on your own classes by defining a to_zon() method that returns a ZonSerializable type:

from dataclasses import dataclass
import natizon
from natizon import ZonSerializable


@dataclass
class ByteSize:
    bytes: int

    def to_zon(self) -> ZonSerializable:
        return f"{self.bytes}B"


data = {
    "cache_limit": ByteSize(1024),
    "buffer_size": ByteSize(2048),
}

zon_string = natizon.dumps(data, indent=2)
print(zon_string)

Output:

.{
  .cache_limit = "1024B",
  .buffer_size = "2048B",
}

License

This project is licensed under the Apache License 2.0. See the LICENSES directory for the full license text.

Metadata

Release files for natizon 0.4.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for natizon 0.4.6
File Size Uploaded Provenance
natizon-0.4.6.tar.gz 20.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for natizon 0.4.6
File Interpreter ABI Platform
natizon-0.4.6-py3-none-any.whl Python 3 none any Details

Total release size: 42.9 kB

Release files / natizon-0.4.6.tar.gz

Download URL natizon-0.4.6.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
23477f058d30415d8651e1085e372bc154f788e108a40a8785e1dba5ac486602
BLAKE2b-256 checksum
How to use checksums
7dbc2dc3b562b21950452d526374be975902f72807277ff509328301030e7456
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / natizon-0.4.6-py3-none-any.whl

Download URL natizon-0.4.6-py3-none-any.whl
Size 22.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
93dd827781730ab38706fa370513fdf583fe307daa83d7d14f6464325a2b1dea
BLAKE2b-256 checksum
How to use checksums
f5311256d774b509cc021280716bb69b858c65ef06145b7a664a364f4cb5d911
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for natizon 0.4.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for natizon-0.4.6.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page