API Reference
iconv-lite
Pure JavaScript character encoding conversion supporting many legacy encodings beyond UTF-8.
Official Documentation ↗CompatibilityThis documentation covers version
v0.6. Check the official docs for the latest API surface.Installation
npm
npm install iconv-liteMethods
No methods match this filter.
iconv-lite converts Buffers between encodings, useful when reading files or responses in legacy charsets.
Key Features
- Pure JS, no native build step
- Streaming decoder support
- Wide legacy encoding coverage
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Errors
The official API reference declares the following error types:
TypeError(无效替换值或其它返回值会 throws 一个 TypeError) — official text: “Replacement text must be representable in the target encoding. An invalid replacement or any other return value throws aTypeError, without calling the handler recursively.” (source: https://raw.githubusercontent.com/ashtuchkin/iconv-lite/master/README.md, fetched 2026-11-08T17:51:40.000Z)
FAQ
- Can it stream?
- Yes. iconv.decodeStream(encoding) returns a transform you can pipe so large files are decoded in chunks.
- Why do I see replacement characters?
- A character not representable in the target encoding becomes a replacement or a question mark; verify the source encoding is correct.
- Does it support UTF-16?
- Yes. UTF-16LE and UTF-16BE are supported, and BOM handling follows the specified encoding.
Report a problem with this API docOpens a pre-filled issue on GitHub.