Skip to main content

k6 inspect

Inspect a script or archive and output its configuration as JSON.

Synopsis

k6 inspect [flags] <file>

Description

The k6 inspect command analyzes a k6 test script or archive and outputs its configuration in JSON format. This is useful for:
  • Understanding what options are configured in a script
  • Debugging configuration issues
  • Validating test configuration before execution
  • Calculating execution requirements
The command parses the script, extracts all options (from both the script and CLI flags), and outputs them in a structured format.

Arguments

file
string
required
Path to the script file or archive to inspect

Examples

# Inspect a script and view its configuration
k6 inspect script.js

# Inspect with execution requirements calculation
k6 inspect --execution-requirements script.js

# Inspect an archive
k6 inspect archive.tar

# Parse and format the output with jq
k6 inspect script.js | jq .

Flags

--execution-requirements
boolean
Include calculations of execution requirements for the test. This adds:
  • totalDuration - The total expected duration of the test
  • maxVUs - The maximum number of VUs that will be used

Runtime Options

The following runtime option flags are also available:
-e, --env
string[]
Add/override environment variable with VAR=value
--include-system-env-vars
boolean
Pass the real system environment variables to the runtime
--compatibility-mode
string
default:"extended"
JavaScript compatibility mode: extended or base
-t, --type
string
Override test type: js or archive

Output Format

Standard Output

The standard output contains the test’s lib.Options structure:
{
  "vus": 10,
  "duration": "30s",
  "iterations": null,
  "scenarios": {
    "default": {
      "executor": "ramping-vus",
      "stages": [
        { "duration": "10s", "target": 10 },
        { "duration": "20s", "target": 0 }
      ]
    }
  },
  "thresholds": {
    "http_req_duration": ["p(95)<500"]
  }
}

Extended Output (with —execution-requirements)

With the --execution-requirements flag, additional fields are included:
{
  "vus": 10,
  "duration": "30s",
  "scenarios": { ... },
  "totalDuration": "30s",
  "maxVUs": 10
}

Use Cases

Pre-flight Validation

Validate your test configuration before running:
k6 inspect script.js --execution-requirements | jq '.maxVUs'

Configuration Debugging

Check how options from different sources are merged:
k6 inspect script.js -e MY_VAR=value | jq '.'

Capacity Planning

Calculate resource requirements:
k6 inspect --execution-requirements script.js | jq '{duration: .totalDuration, maxVUs: .maxVUs}'

Exit Codes

  • 0 - Inspection successful
  • Non-zero - Error occurred (invalid script, parsing error, etc.)

See Also

Build docs developers (and LLMs) love