← All notes

Node.js string_decoder: decode buffers into strings safely

Answer: The node:string_decoder module decodes Buffer objects into strings while preserving multi-byte UTF-8 and UTF-16 characters. new StringDecoder(encoding) creates a decoder. After end() runs, the same decoder can be reused.

Examples

import { StringDecoder } from 'node:string_decoder';
const decoder = new StringDecoder('utf8');

Notes

end() returns any remaining input stored in the internal buffer as a string. The module is stable.

Reference list

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Node.js docs, String decoder; Node.js, string_decoder.md. MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE). Copyright Node.js contributors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Node.js docs, String decoder; Node.js, string_decoder.md. MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE). Copyright Node.js contributors.

Cite this

Permanent ID: iil:note:h3knwmtx

iinventedlight. 2026. "Node.js string_decoder: decode buffers into strings safely." iinventedlight Library, iil:note:h3knwmtx, version of 2026-11-18. https://iinventedlight.com/library/notes/node-string-decoder/. License: CC-BY-4.0.

@misc{iil_note_h3knwmtx,
  author = {{iinventedlight}},
  title = {{Node.js string\_decoder: decode buffers into strings safely}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/node-string-decoder/},
  note = {Permanent ID iil:note:h3knwmtx. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/node-string-decoder.md.