# iconv-lite — card for AI agents

Converts text between character encodings (Windows-1251, Shift_JIS and more) in pure JavaScript.

Category: Utilities · npm package `iconv-lite` · latest version 0.7.3 (checked 2026-11-01)
Install: `npm install iconv-lite`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Numbers (AgentGid data)
- Gid Score: 61.8 (#891 of all tools, 105 of 408 in its category)
- Used in 10 public projects set up for AI coding agents (0.2%)
- Downloads last week: 449,417,679 (as of 2026-11-24), +42.2% over 4 weeks
- GitHub stars: 3,186 (as of 2026-11-24)
- Last push: 2026-11-23

## Often used with
Zod 77.4%, Vitest 67.7%, Vite 64.5%, tsx 54.8%, dotenv 54.8%, jsdom 45.2%

## Links
- AgentGid page: https://agentgid.com/tools/iconv-lite/
- Homepage: https://github.com/pillarjs/iconv-lite
- Repository: https://github.com/pillarjs/iconv-lite


## iconv-lite: read and write text in older encodings

iconv-lite is a free JavaScript library that turns text saved in older character sets, such as Windows-1252, Shift_JIS or GBK, into normal text your app can show, and back. Without it, such files show up as question marks and broken symbols. It is plain JavaScript, so nothing has to be compiled when you install it.

### Where to use it
- Open files from older programs: A customer uploads a price list saved by an old Windows or Japanese office program; your app shows the names correctly instead of broken symbols.
- Send files to an older system: A bank, shop till or warehouse system only accepts files in its own character set; your app writes the export in exactly that set.
- Accept form posts in other encodings: A server receives form posts or callbacks from older systems that are not in UTF-8 and reads them correctly; the popular Express body reader relies on it.
- Convert large files piece by piece: A nightly job turns big old exports into UTF-8 without loading the whole file into memory at once.
- Scrape pages in older encodings: A scraper fetches a Japanese or Chinese page that declares Shift_JIS or GBK and turns the raw bytes into readable text before parsing it. (idea, not from the official pages)

### How to start
- Add the stable version (0.7.x) to your project; it works with require in any Node.js version.

```
npm install iconv-lite@0.7.3
```

- Decode bytes into text, or encode text into bytes, naming the character set.

```
var iconv = require('iconv-lite');

// Convert from an encoded buffer to a js string.
str = iconv.decode(Buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f]), 'win1251');

// Convert from a js string to an encoded buffer.
buf = iconv.encode("Sample input string", 'win1251');
```


### License
Free to use, change and sell as part of your product under the MIT license. Keep its copyright and license notice in copies of the package you ship.

### Good to know
- It does not guess the character set. Your code has to know it, for example from the file's source or a page header.
- Characters the target set lacks become question marks or a replacement sign; it does not swap them for similar letters.
- In the browser it needs a build tool and a shim for Node.js's binary data type, about 180 kB compressed in total.
- Version 1.0 is in beta. It works only as a modern module on Node.js 22 or newer, and the old require call stops working.

Checked 2026-11-10 against: https://github.com/pillarjs/iconv-lite/blob/v0.7.3/README.md, https://github.com/pillarjs/iconv-lite/blob/v0.7.3/LICENSE, https://github.com/pillarjs/iconv-lite/blob/master/README.md, https://github.com/pillarjs/iconv-lite/blob/master/Changelog.md, https://registry.npmjs.org/iconv-lite, https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz

### Mistakes to avoid
- Don't: fs.readFileSync('old.csv', 'utf8') and then iconv.decode(text, 'windows-1252') → Do: fs.readFileSync('old.csv') (no encoding, so you get a Buffer) and then iconv.decode(bytes, 'windows-1252') (Reading as UTF-8 first already destroys the bytes; decode needs the raw Buffer.)
- Don't: Copying import iconv from 'iconv-lite' and the Node.js 22 setup from the GitHub front page into a project on 0.7.3, or upgrading to 1.0 while keeping require('iconv-lite') → Do: Stay on iconv-lite@0.7.3 with require, or move to 1.0 together with ES module imports and Node.js 22+ (The main-branch README already describes 1.0, where require is no longer a supported entry point.)
- Don't: Expecting iconv.encode('Café 世界', 'ascii') to give 'Cafe ...' style replacements → Do: Pick a target set that has the characters, or replace them yourself before encoding (Missing characters become ? (our run turned 'Hello 世界' in latin1 into 'Hello ??').)
- Don't: Expecting iconv.encode(text, 'utf8') output to start with a byte order mark → Do: Pass { addBOM: true } when the receiving program needs one (No BOM is written unless you ask for it.)
- Don't: Calling iconv.decodeStream in React Native without a stream module → Do: Install a stream module first, as the README says, or use the one-shot decode (The streaming API needs the stream module, which React Native does not ship.)

### Questions
- Can I use it in a paid, closed-source app? Yes. It is MIT licensed; keep the copyright and license notice with the package.
- Why do I still get broken symbols after decoding? Most often the file was first read as UTF-8 text, so the original bytes are gone. Read it as raw bytes (a Buffer) and decode that.
- Which character sets does it know? The Windows 125x and ISO-8859 families, DOS and Mac code pages, KOI8, the UTF-16 and UTF-32 variants, and Asian sets such as Shift_JIS, EUC-JP, GBK, GB18030 and Big5.
- Does it add a byte order mark when saving? No, not unless you ask for it with the addBOM option; when reading, it removes one by default.
- Is it maintained? Yes. 0.7.3 came out on 3 July 2026 and version 1.0 is in beta.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
