k6 TextEncoder and TextDecoder globals
Introduced 2026-08-10 · score 0.96
HOW TO USE IT
When a k6 script must encode or decode text, use the `TextEncoder` and `TextDecoder` globals directly in init or VU code. No import is required.
const encoded = new TextEncoder().encode('Hello, world!');
const decoded = new TextDecoder().decode(encoded);WHY THIS HELPS
When encoding or decoding text in a k6 script, use the standard encoder and decoder globals in init or VU code.
REQUIREMENTS AND LIMITATIONS
- Version: v2.2.0
- Prerequisite: Use k6 v2.2.0 or later; the release note says these globals are available in both init and VU contexts.
- Available as globals in both the init and VU contexts.
FIRST-PARTY EVIDENCE
Check the installed version and the source before using it. Entry JSON