Jsonnet Formatter & Evaluator
Format Jsonnet source with consistent indentation, or evaluate it to JSON — objects with inheritance (self/super), locals, functions, comprehensions, string interpolation, and a substantial subset of the std library. import/importstr are not supported (no filesystem access in-browser). Runs entirely in your browser.
Input
Options
Output
Guides
Paste Jsonnet source — Google's JSON-superset templating language, used heavily for Kubernetes manifests and Grafana dashboards — and either evaluate it to plain JSON or format the Jsonnet source itself with consistent indentation. Objects, arrays, local bindings, functions, comprehensions, string interpolation, and object inheritance via +/self/super are all supported. Everything runs locally in your browser.
How to use it
- Paste your Jsonnet source, or upload a
.jsonnet/.libsonnetfile. - Choose a Mode: Evaluate → JSON runs the program and shows the resulting JSON value; Format Jsonnet source re-prints the Jsonnet itself with clean indentation (no evaluation).
- Pick an Indent width (2/4 spaces, tab, or — in evaluate mode — minified with no whitespace at all).
- In evaluate mode, turn on Sort object keys alphabetically to normalize key order, or Force string output when the top-level expression is meant to produce a single string (useful for generating a config file's raw text rather than a JSON document).
What it supports
- Objects with
+inheritance,self/super, hidden (::) and forced-visible (:::) fields, and method-style fields. - Arrays, array/object comprehensions (
[x*2 for x in arr if x > 0]), and slicing. localbindings (including functions),if/then/else,function(...)with default parameter values.- String interpolation via
%(std.format, e.g."%s-%03d" % [name, n]),|||text blocks, and@"..."verbatim strings. - Around 50
std.*library functions:length,map/filter/foldl/foldr,join/split, string case/strip helpers,objectFields/objectValues/mergePatch,sort/uniq/reverse, numeric helpers,manifestJson*, and more.
What's out of scope?
import, importstr, and importbin raise a clear error instead of silently doing nothing — evaluating them would require reading other files, which an isomorphic, browser-safe tool can't do. This covers a substantial, commonly-used subset of the language and standard library for config/manifest-style Jsonnet, but hasn't been exhaustively verified against every edge case of the official spec — if a specific construct behaves unexpectedly, treat the reference jsonnet CLI as the source of truth.
Does the formatter preserve comments?
No — //, #, and /* */ comments are discarded before formatting, the same tradeoff the GraphQL Schema Formatter documents for GraphQL's # comments (the tokenizer never keeps them, so there's nothing for the printer to put back). Everything else — string values, object structure, function bodies — is preserved exactly.
Is my source uploaded anywhere?
No. Tokenizing, parsing, evaluating, and formatting all run locally in your browser; your Jsonnet source is never sent to a server.
Need to work with the resulting JSON, or a different templating language?
Use the JSON Formatter to reformat or minify the evaluated output, or the Terraform Formatter if your infrastructure config is HCL rather than Jsonnet.
Use it from code
From 3 credits per callREST API
curl -X POST https://api.iotools.cloud/v1/tool/jsonnet-formatter-evaluator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jsonnetInput": "local name = 'hello';\nlocal image = 'nginx:1.27'…",
"jsonnetMode": "evaluate",
"jsonnetIndent": "2",
"jsonnetSortKeys": "",
"jsonnetStringOutput": ""
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `jsonnet-formatter-evaluator` tool (Jsonnet Formatter & Evaluator) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.