Skip to main content
With k6 extensions, you can extend the core k6 functionality with new features to support your specific reliability-testing needs.

Extension types

k6 supports four types of extensions:

JavaScript Extensions

Extend the JavaScript APIs available to your test scripts. Add support for new network protocols, improve performance, or add features.

Output Extensions

Send metrics to a custom file format or service. Add custom processing and dispatching methods.

Secret Source Extensions

Provide secrets to your tests from external sources.

Subcommand Extensions

Add custom CLI commands under the k6 x namespace for setup, validation, and integration tools.

Official vs community extensions

Official extensions

These extensions are owned and maintained by Grafana Labs, with support for a wide range of k6 versions. Official extensions include:
  • k6/x/mqtt - MQTT protocol support
  • k6/x/redis - Redis database interaction
  • k6/x/sql - SQL database testing
  • k6 browser - Browser automation and end-to-end testing
  • xk6-disruptor - Chaos testing and fault injection
Explore the full list in Explore Extensions.

Community extensions

Community extensions are developed by the k6 ecosystem, supporting specific versions. While not maintained by Grafana Labs, many provide valuable functionality for specialized testing needs.
Many extensions maintained by members of the k6 ecosystem are available on GitHub. These extensions aren’t maintained nor audited by Grafana Labs.

Using extensions

There are two ways to use extensions in your k6 tests:

Automatic extension resolution

Official and community extensions can be used without additional configuration. Simply import them in your test script:
import faker from 'k6/x/faker';

export default function () {
  console.log(faker.person.firstName());
}
Then run your script normally:
k6 run script.js
To use community extensions, set K6_ENABLE_COMMUNITY_EXTENSIONS=true:
K6_ENABLE_COMMUNITY_EXTENSIONS=true k6 run test.js

Custom k6 binary

For custom extensions or output extensions, build a custom k6 binary using xk6:
xk6 build \
  --with github.com/grafana/[email protected] \
  --with github.com/grafana/xk6-output-influxdb
Learn more in Building Custom k6 Binaries.

Getting started

1

Explore available extensions

Browse the Extensions catalog to find extensions for your use case.
2

Try an extension

Start with an official extension like xk6-disruptor for chaos testing or k6 browser for browser automation.
3

Build your own

Create custom extensions when you need specialized functionality. See Creating Extensions.

Why use extensions?

Extensions enable you to:
  • Test new protocols - Add support for MQTT, Redis, gRPC, and more
  • Integrate with tools - Send metrics to your preferred monitoring systems
  • Enhance performance - Use Go’s speed for computationally intensive operations
  • Customize workflows - Add CLI commands for your specific testing process
  • Manage secrets - Securely inject credentials from external vaults
  • Extend capabilities - Add chaos testing, browser automation, and more

Next steps

Explore Extensions

Find extensions for your testing needs

Create Extensions

Build custom extensions in Go

Bundle Extensions

Build custom k6 binaries with xk6

xk6-disruptor

Inject faults for chaos testing

Build docs developers (and LLMs) love