Skip to main content
Most CLI commands that return data support the --format jsonpath='<expression>' parameter. You can use it to extract values, such as a resource ID, name or IP address, without post-processing the full output. For example, to return only the ID of a virtual machine (VM), add the following parameter to the nebius compute instance create command:
The CLI uses the same JSONPath implementation as kubectl. This implementation extends the original JSONPath syntax with additional functions, such as list iteration, but it doesn’t support all JSONPath features.

Syntax

A JSONPath expression selects values from the JSON object returned by a CLI command. When you write JSONPath expressions for the --format jsonpath parameter, consider the following:
  • Enclose expressions in curly braces. However, if you omit them, the CLI still parses the value. The $ operator is optional because expressions start from the root object by default. As a result, these expressions are equivalent:
  • Use double quotes to quote literal text inside JSONPath expressions:
  • Use the range and end operators to iterate over lists:
  • To step backward through a list, use negative slice indices. The negative indices don’t wrap around a list and are valid if -index + listLength >= 0. For example:
  • Complex values, such as objects or lists, are printed in their string representation. If you need stable machine-readable output for further processing, use --format json.

Common expressions

For more information, see the examples below and Kubernetes JSONPath documentation.

Examples

Getting a value from a single resource

Below are several examples of how to get a value from a single resource:
  • Get a name of a VM:
    Example output:
  • Get a status of a VM:
    Example output:
  • Get a bucket ID by the bucket name:
    Example output:
  • Get a public IP address of a VM by the VM name:
    Example output:

Getting values from a list

Below are several examples of how to get values from a list:
  • Get the name of the first VM from the list:
    Example output:
  • Get names and statuses of all VMs:
    Example output:

Formatting list output

Print each VM name and status on a separate line:
Example output:

Limitations

JSONPath regular expressions aren’t supported. In this context, a regular expression is a pattern used in a JSONPath filter to match field values. For example, the following expression tries to find VMs whose names start with vm:
This expression doesn’t work because the JSONPath implementation used by the CLI doesn’t support the =~ regular expression match operator. The command fails while parsing the JSONPath expression, before matching it against command output. Match values with regular expressions by using jq:
This command requires jq to be installed. Example output: