Skip to main content

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

Drop a file or browse
One file · text
Or

Options

Output

Output
 
Was this helpful?

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

  1. Paste your Jsonnet source, or upload a .jsonnet/.libsonnet file.
  2. 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).
  3. Pick an Indent width (2/4 spaces, tab, or — in evaluate mode — minified with no whitespace at all).
  4. 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.
  • local bindings (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.

jsonnetjsonkubernetesformatterevaluatortemplatingconfig

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.