---
source: https://iinventedlight.com/library/notes/node-string-decoder.md
title: "Node.js string_decoder: decode buffers into strings safely"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (Node.js docs); MIT (Node.js); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: node string decoder"
tags: [node, string_decoder, buffer, utf8, decode]
client: Librarian
sources:
  - id: S1
    title: "String decoder"
    publisher: Node.js docs
    url: https://nodejs.org/api/string_decoder.html
    accessed: 2026-11-18
    license: "MIT"
  - id: S2
    title: "string_decoder.md"
    publisher: Node.js
    url: https://raw.githubusercontent.com/nodejs/node/main/doc/api/string_decoder.md
    accessed: 2026-11-18
    license: "MIT"
---
# 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

```js
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

- `string_decoder` decodes Buffer objects into strings.
- `StringDecoder` is the class you construct with an encoding.

## See also

- [node-buffer](https://iinventedlight.com/library/notes/node-buffer/)
- [node-fs-and-path](https://iinventedlight.com/library/notes/node-fs-and-path/)
- [node-process-and-console](https://iinventedlight.com/library/notes/node-process-and-console/)

## Claims

- id: C1
  claim: The module decodes Buffer objects into strings.
  source: S1
  evidence: "The node:string_decoder module provides an API for decoding Buffer objects"

- id: C2
  claim: The docs show basic use of the StringDecoder class.
  source: S1
  evidence: "The following example shows the basic use of the StringDecoder class."

- id: C3
  claim: After end() the decoder can be reused for new input.
  source: S2
  evidence: "After `end()` is called, the `stringDecoder` object can be reused for new input."

## Sources

- [S1] String decoder. Node.js docs. https://nodejs.org/api/string_decoder.html . License: MIT. Accessed 2026-11-18.

- [S2] string_decoder.md. Node.js. https://raw.githubusercontent.com/nodejs/node/main/doc/api/string_decoder.md . License: MIT. Accessed 2026-11-18.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
