[ Web Proxy ]
URL:
Viewing: https://developers.cloudflare.com/workers/runtime-apis/nodejs/string-decoder/ [Back]  [Original]

StringDecoder Cloudflare Workers docsSkip to content
SearchCtrlKLog in
  1. Home
  2. /Workers
  3. /
  4. /Node.js compatibility
  5. /StringDecoder

StringDecoder

Last updated Apr 23, 2026Copy as MarkdownView as MarkdownAgent setup

Note

For compatibility dates of 2026-08-04 or later, Workers enables both nodejs_compat and nodejs_compat_v2 by default. These flags are not used for these compatibility dates. Existing projects do not need to remove them when updating their compatibility date. For earlier dates, add nodejs_compat to your Wrangler configuration file to opt in. For instructions to turn off Node.js compatibility, refer to the Node.js compatibility flag.

The node:string_decoder is a legacy utility module that predates the WHATWG standard TextEncoder and TextDecoder API. In most cases, you should use TextEncoder and TextDecoder instead. StringDecoder is available in the Workers runtime primarily for compatibility with existing npm packages that rely on it. StringDecoder can be accessed using:

const { StringDecoder } = require("node:string_decoder");
const decoder = new StringDecoder("utf8");

const cent = Buffer.from([0xc2, 0xa2]);
console.log(decoder.write(cent));

const euro = Buffer.from([0xe2, 0x82, 0xac]);
console.log(decoder.write(euro));

Refer to the Node.js documentation for string_decoder for more information.

PreviousStreamsNexttest

Was this helpful?

YesNo
Edit pageReport issue
[]

Web Proxy Viewer  |  New URL  |  Original Page