--- layout: default title: Tooling ---

# Tooling

Aside from the Jsonnet interpreters (which execute the Jsonnet code) these additional software tools allow you to get the most out of Jsonnet:

- Formatter, for automatically fixing stylistic problems
- Linter, for drawing attention to red flags that cannot be fixed automatically
- Bazel rules, for config generation as part of your build system
- Editor integration for syntax highlighting and other features
  - Heptio maintain a vscode extension with quite sophisticated program analysis
  - Vim
  - Codemirror, the editor widget used by this website
  - Atom
  - Sublime
  - Databricks maintain an IntelliJ plugin with jump to imported files and local variables.
  - An Emacs mode is also available.

## Formatter Demo

The formatter is a command-line utility bundled with the C++ build of Jsonnet. You can reformat files in place as so:

    jsonnetfmt -i *.jsonnet

It will manage indenting and horizontal spacing within a line and remove excess vertical spacing. It will convert string literals, comments, fields and some operators into canonical forms as well as enforcing trailing commas. It will sort imports and remove excess nesting of parentheses. It will break lines in certain places.

# Edit me! local b = import "b.libsonnet"; # comment local a = import "a.libsonnet"; local f(x,y)=x+y; local Template = {z: "foo"}; Template + { "f": ((3)) , "g g": f(4,2), arr: [[ 1, 2, ], 3, ] }
➡
output.jsonnet
// Edit me! local a = import 'a.libsonnet'; local b = import 'b.libsonnet'; // comment local f(x, y) = x + y; local Template = { z: 'foo' }; Template { f: (3), 'g g': f(4, 2), arr: [ [ 1, 2, ], 3, ], }

## Linter

The linter is another command-line utility bundled with the Go build of Jsonnet. You can check files as so:

    jsonnet-lint file.jsonnet

Currently it is rudimentary and only checks for unused variables.

## Bazel Jsonnet Rules

Jsonnet rules, provides the following rules to your Babel build:

    jsonnet_library

    jsonnet_to_json

    jsonnet_to_json_test