jsonnet
Python bindings for Jsonnet - The data templating language
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 jsonnetuv
uv add jsonnetpoetry
poetry add jsonnetInstalling 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
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
empyEmPy is a templating system that embeds Python…
permissive · top 15,000 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
jsonargparsejsonargparse creates command-line interfaces…
permissive · top 5,000 on PyPI
json-eParameterizes and transforms JSON data…
copyleft · top 5,000 on PyPI
sphinxcontrib.datatemplatesA Sphinx extension that renders…
permissive · top 15,000 on PyPI
TempitaTempita is a lightweight templating engine that…
permissive · top 15,000 on PyPI
yteYTE is a YAML template engine that embeds…
permissive · top 15,000 on PyPI
zope.pagetemplatezope.pagetemplate provides a templating system…
unclear · top 15,000 on PyPI
django-jinjaIntegrates Jinja2 templating into Django,…
permissive · top 15,000 on PyPI
htmlBuilderRender HTML by writing Python code, using…
permissive · top 15,000 on PyPI