Skip to main content
The k6/experimental module provides access to experimental APIs and features that are under development or evaluation for inclusion in k6.
Experimental modules may have breaking changes in future releases. Use them to test new features, but be prepared to update your scripts when APIs change or stabilize.

Overview

Experimental modules allow you to try new k6 features before they become stable. Features that prove useful and stable are eventually promoted to regular k6 modules.

Importing Experimental Modules

import csv from 'k6/experimental/csv';
import { open } from 'k6/experimental/fs';
import { ReadableStream } from 'k6/experimental/streams';

Available Experimental Modules

CSV Module

Provides efficient and convenient parsing of CSV files with better performance than JavaScript-based libraries.

csv

Efficient CSV file parsing and streaming
Key Features:
  • Fast parsing using Go-based processing
  • Lower memory usage with SharedArray support
  • Line-by-line streaming for large files
  • Full-file parsing for performance-critical scenarios
Example:
import csv from 'k6/experimental/csv';
import { open } from 'k6/experimental/fs';

const file = await open('data.csv');
const csvRecords = await csv.parse(file, { delimiter: ',' });

export default async function () {
  console.log(csvRecords[0]); // First CSV record
}

Filesystem Module

Provides memory-efficient file interactions within test scripts, including reading files, seeking, and retrieving metadata.

fs

Memory-efficient file system operations
Key Features:
  • Memory-efficient file loading (shared across VUs)
  • File seeking and random access
  • File metadata and stats
  • Async file operations
Example:
import { open, SeekMode } from 'k6/experimental/fs';

const file = await open('data.txt');

export default async function () {
  await file.seek(0, SeekMode.Start);
  
  const buffer = new Uint8Array(1024);
  const bytesRead = await file.read(buffer);
  
  console.log(`Read ${bytesRead} bytes`);
}

Streams Module

Implements the Streams API specification for defining and consuming readable streams.

streams

Streams API for reading and transforming data
Key Features:
  • ReadableStream implementation
  • Transform streams
  • Backpressure handling
  • Integration with other k6 modules
Example:
import { ReadableStream } from 'k6/experimental/streams';

const stream = new ReadableStream({
  start(controller) {
    controller.enqueue('chunk 1');
    controller.enqueue('chunk 2');
    controller.close();
  }
});

export default async function () {
  const reader = stream.getReader();
  
  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    console.log('Read:', value);
  }
}

Module Comparison

CSV Module

ApproachMemory UsagePerformanceUse Case
csv.parse()Higher (full file)FasterPerformance-critical scenarios
csv.ParserLower (streaming)ModerateLarge files, memory constraints

Filesystem vs Traditional open()

Featureexperimental/fsTraditional open()
Memory UsageLow (shared)High (per-VU copy)
File SizeAny sizeLimited by memory
Random AccessYes (seeking)No
Read ModeStreamingFull load

API Reference Summary

k6/experimental/csv

csv.parse(file, options)
function
Parses entire CSV file into a SharedArray
csv.Parser
class
Streaming CSV parser for line-by-line reading

k6/experimental/fs

open(filePath)
function
Opens a file and returns a File instance
File
class
Represents a file with read(), seek(), and stat() methods
SeekMode
enum
Enum for seek operations: Start, Current, End

k6/experimental/streams

ReadableStream
class
Implements the Streams API ReadableStream

Best Practices

Using Experimental Features

Experimental APIs may change between k6 versions. Pin your k6 version in CI/CD to avoid unexpected breaking changes.
docker run --rm -i grafana/k6:0.48.0 run - <script.js
Check k6 release notes for deprecation warnings and migration paths when experimental modules are stabilized or changed.
Thoroughly test scripts using experimental modules in non-production environments before deploying to production load tests.
Be prepared to refactor if an experimental module is removed or significantly changed in future k6 versions.

Migration Paths

Some experimental modules have been promoted to stable:
Former Experimental ModuleStable Module
k6/experimental/browserk6/browser
k6/experimental/websocketsk6/websockets
k6/experimental/grpck6/net/grpc
k6/experimental/timersk6/timers
When an experimental module is promoted to stable, the old import path usually continues to work for a few versions with deprecation warnings.

Examples

Combining CSV and Filesystem

import csv from 'k6/experimental/csv';
import { open } from 'k6/experimental/fs';
import { scenario } from 'k6/execution';

export const options = {
  iterations: 100,
};

const file = await open('users.csv');
const users = await csv.parse(file, { delimiter: ',' });

export default async function () {
  // Each iteration gets a unique user
  const user = users[scenario.iterationInTest % users.length];
  console.log(`Testing with user: ${user[0]}`);
}

Streaming Large Files

import csv from 'k6/experimental/csv';
import { open } from 'k6/experimental/fs';

const file = await open('large-dataset.csv');
const parser = new csv.Parser(file);

export default async function () {
  // Read one line per iteration
  const { done, value } = await parser.next();
  
  if (!done) {
    console.log('Processing row:', value);
  } else {
    console.log('Reached end of file');
  }
}

CSV Module

Efficient CSV parsing

Filesystem Module

Memory-efficient file operations

Streams API

Data streaming support

k6 Changelog

Track experimental module changes

Build docs developers (and LLMs) love