skillfed

jsonnet

Python bindings for Jsonnet - The data templating language

jsonnet v0.22.0 2.1M downloads/30d#3,260 on PyPI7,553
Permissive license Apache-2.0 Active released

What it is and what it does

Jsonnet is a templating language designed to generate JSON from higher-level, more expressive syntax. This package provides Python bindings to the original C++ implementation, allowing you to evaluate Jsonnet code from Python and receive JSON output. The main entry points are `evaluate_file()` to process Jsonnet files and `evaluate_snippet()` to evaluate code strings directly.

The package supports passing variables into Jsonnet code via `ext_vars` and `ext_codes`, top-level function arguments via `tla_vars` and `tla_codes`, and custom functions callable from Jsonnet via `native_callbacks`. The documentation explicitly warns that the C++ implementation is not hardened against untrusted inputs and should only be used to evaluate code you trust.

Use it for:

  • Generate complex JSON configurations programmatically from templates with variables and functions.
  • Build infrastructure-as-code JSON from reusable Jsonnet libraries.
  • Evaluate Jsonnet as a higher-level configuration language in Python applications.
  • Pass external variables and top-level arguments into Jsonnet code from Python.
  • Expose Python functions to Jsonnet code via native_callbacks for domain-specific logic.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Jsonnet is a data templating language that evaluates Jsonnet code to produce JSON output, with Python bindings to the original C++ implementation.

Yes, if you need to generate or template JSON from Jsonnet code in Python and trust the Jsonnet source. The package is actively maintained, has no known vulnerabilities, and wheels cover common platforms. However, do not use it to evaluate untrusted Jsonnet code without external sandboxing—the C++ implementation is not hardened.

Install

jsonnet on PyPI

pip

pip install jsonnet

uv

uv add jsonnet

poetry

poetry add jsonnet

Installing jsonnet

Before you install

Medium install friction due to compiled C++ bindings, but wheels are available for common platforms (macOS ARM64, Linux x86_64, Windows x64, and musllinux). Repository is actively maintained with recent commits.

License in practice

Apache-2.0 permissive license allows commercial and private use with minimal restrictions; you must include a copy of the license and notice of modifications.

Quickstart

import _jsonnet

result = _jsonnet.evaluate_snippet(
    'example',
    '{ greeting: "hello" }'
)
print(result)

The C++ implementation is not suitable for processing untrusted inputs without sandboxing; import, importstr, and importbin language constructs can access any path the interpreter can reach.

Verify before relying

  • Whether pre-built wheels cover all target deployment platforms beyond the listed architectures.
  • Specific Python version compatibility (requires_python is unspecified in metadata).

Package facts

License Apache-2.0 (permissive)
Python support not specified
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance actively maintained — 143 days since the last release
Last repo commit
First released
Downloads 2,138,994/month — #3,260 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: jsonnet-0.22.0-cp314-cp314t-macosx_11_0_arm64.whl; jsonnet-0.22.0-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; jsonnet-0.22.0-cp314-cp314t-musllinux_1_2_x86_64.whl; jsonnet-0.22.0-cp314-cp314t-win_amd64.whl; jsonnet-0.22.0-cp38-abi3-macosx_11_0_arm64.whl; jsonnet-0.22.0-cp38-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; jsonnet-0.22.0-cp38-abi3-musllinux_1_2_x86_64.whl; jsonnet-0.22.0-cp38-abi3-win_amd64.whl

Tags

jsonnet templating languagejson data generationconfiguration templatingjsonnet python bindingsevaluate jsonnet codejson template enginedata templating
templatingjson-generationconfiguration-management

More Text Processing packages