> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/grafana/k6/llms.txt
> Use this file to discover all available pages before exploring further.

# k6 inspect

> Inspect a k6 script or archive

# k6 inspect

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

## Synopsis

```bash theme={null}
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

<ParamField path="file" type="string" required>
  Path to the script file or archive to inspect
</ParamField>

## Examples

```bash theme={null}
# 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

<ParamField path="--execution-requirements" type="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
</ParamField>

### Runtime Options

The following runtime option flags are also available:

<ParamField path="-e, --env" type="string[]">
  Add/override environment variable with `VAR=value`
</ParamField>

<ParamField path="--include-system-env-vars" type="boolean">
  Pass the real system environment variables to the runtime
</ParamField>

<ParamField path="--compatibility-mode" type="string" default="extended">
  JavaScript compatibility mode: `extended` or `base`
</ParamField>

<ParamField path="-t, --type" type="string">
  Override test type: `js` or `archive`
</ParamField>

## Output Format

### Standard Output

The standard output contains the test's `lib.Options` structure:

```json theme={null}
{
  "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:

```json theme={null}
{
  "vus": 10,
  "duration": "30s",
  "scenarios": { ... },
  "totalDuration": "30s",
  "maxVUs": 10
}
```

## Use Cases

### Pre-flight Validation

Validate your test configuration before running:

```bash theme={null}
k6 inspect script.js --execution-requirements | jq '.maxVUs'
```

### Configuration Debugging

Check how options from different sources are merged:

```bash theme={null}
k6 inspect script.js -e MY_VAR=value | jq '.'
```

### Capacity Planning

Calculate resource requirements:

```bash theme={null}
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

* [k6 run](/cli/run) - Run a test
* [k6 archive](/cli/archive) - Create an archive
* [Configuration file format](/cli/configuration-file)
