NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm
npm, #4499 most downloaded on npm
Convert and detect character encodings in JavaScript
Latest stable
2.5.0
Last release 20 days ago
02 Nov 2026
Release timing varies
gaps range from 2 weeks to 2.5 years
Nearly every release is documented
notes for 16 of 16 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
16 releases · first in 2014
Drag across the ruler to compare, or tap a release to open it.
This release has no breaking API changes and focuses on making encoding.js faster and smaller: a roughly 60% reduction in minified bundle size, faster
This release has no breaking API changes and focuses on making encoding.js faster and smaller: a roughly 60% reduction in minified bundle size, faster character encoding conversions, and lower memory usage.
And I've finally set up GitHub Sponsors!
EncodingName, allow string input in urlEncode() and base64Encode(), and accept typed arrays in the Zenkaku/Hankaku conversion functions (d769950)0x2237 from EUCJP and JIS by @youdie006 in #69UTF8, preventing the previous character from being repeated (#71)U+10FFFF when converting from UNICODE to UTF8 (#71)codeToString() and string output potentially throwing a RangeError on a deep call stack (055ede8)base64Decode() to ignore non-ASCII characters (61e7dc2)convert() to return a new array even when no conversion is needed (86f2a7e)Reduced the bundle size by compressing the UTF-8 to JIS conversion tables into a compact text format. Conversion results and APIs are unchanged.
The tables are expanded lazily only when a conversion is actually needed, rather than at module load time, to avoid unnecessary initialization overhead. See #70 for more details.
| v2.4.0 | v2.5.0 | Change | |
|---|---|---|---|
encoding.js |
304 KB | 148 KB | -51% |
encoding.min.js |
229 KB | 88 KB | -62% |
encoding.min.js (gzip) |
76 KB | 39 KB | -49% |
Improved conversion performance by prioritizing typed arrays.
This makes convert() about 1.5-3.5x faster for most encoding pairs (about 1.3x when converting from UTF-8) and reduces peak memory during conversion by about 25-60%.
Selected benchmark results from #71 (in ops/sec, higher is better):
| Conversion | v2.4.0 | v2.5.0 | Speedup |
|---|---|---|---|
| SJIS -> UNICODE | 64.51 | 160 | 2.5x |
| EUCJP -> UNICODE | 65.96 | 182 | 2.8x |
| UNICODE -> SJIS | 23.63 | 54.25 | 2.3x |
| UNICODE -> UTF8 | 54.85 | 183 | 3.3x |
| SJIS -> UTF8 | 84.82 | 154 | 1.8x |
| UTF8 -> SJIS | 62.02 | 79.35 | 1.3x |
Benchmark on Node.js v24 with the full text of "I Am a Cat" (about 350,000 characters), type: 'array'.
Other performance improvements:
codeToString() and string output performance by keeping the fast conversion path available after processing large arrays (055ede8)stringToCode(), base64Encode(), urlDecode() and the Zenkaku/Hankaku conversion functions by preallocating result arrays, up to about 3x faster for large input (055ede8, cf887c6)encoding.min.js ES5-compatible (9a8d3b2)I've started GitHub Sponsors! If encoding.js is useful to you, please consider supporting my work. Your support would mean a lot. Thank you!
Full Changelog: 2.4.0...2.5.0
Your coding agent can read these notes before it upgrades. Set up the MCP server →
EncodingName to support case-insensitive encoding names and aliases, allow strings in urlEncode() and base64Encode(), and accept typed arrays in the Zenkaku/Hankaku conversion functions. (d769950)0x2237 being decoded with an extra NUL byte (expected [0x7E], but got [0x00, 0x7E]) on conversion from EUCJP and JIS. (#69) Thanks @youdie006UTF8, preventing the previous character from being repeated (e.g., [0xE3, 0x81, 0x82, 0x80] now decodes to あ instead of ああ). (#71)U+10FFFF when converting from UNICODE to UTF8. (#71)codeToString() and string output possibly throwing a RangeError when called on a deep call stack. It now falls back to a simple loop. (055ede8)base64Decode() to ignore non-ASCII characters. (61e7dc2)convert() to return a new array even when no conversion is needed (e.g., SJIS to SJIS, or to BINARY). (86f2a7e)encoding.min.js: 229 KB -> 88 KB, 76 KB -> 39 KB gzipped). Conversion results and APIs are unchanged. (#70)convert() is about 1.5-3.5x faster for most encoding pairs, and peak memory during conversion is reduced by about 25-60%. (#71)codeToString() and string output performance by keeping the fast conversion path available after processing large arrays. (055ede8)stringToCode(), base64Encode(), urlDecode() and the Zenkaku/Hankaku conversion functions by preallocating result arrays (up to about 3x faster for large input). (055ede8, cf887c6)Include TypeScript definitions (index.d.ts) migrated from DefinitelyTyped. Installing @types/encoding-japanese separately is no longer required. Thank
Include TypeScript definitions (index.d.ts) migrated from DefinitelyTyped. Installing @types/encoding-japanese separately is no longer required. Thanks to DefinitelyTyped contributors!
index.d.ts and the "types" field to package.json@types/encoding-japanese 2.2.1.SJIS, EUCJP and JIS in https://github.com/polygonplanet/encoding.js/pull/67U+301C (〜) being mapped to JIS X 0212 instead of JIS X 0208 when converting to EUCJP and JIS (e.g., 0x8FA1C1 instead of 0xA1C1 in EUCJP) in https://github.com/polygonplanet/encoding.js/pull/670x7F being converted as 0x7E instead of falling back to ? on conversion from SJIS (b848595)tsc, and include them in npm test (https://github.com/polygonplanet/encoding.js/pull/68).eslintrc.json to flat config with @stylistic/eslint-plugin (https://github.com/polygonplanet/encoding.js/pull/66)Full Changelog: https://github.com/polygonplanet/encoding.js/compare/2.3.0...2.4.0
index.d.ts) migrated from DefinitelyTyped. Installing @types/encoding-japanese separately is no longer required. Thanks to DefinitelyTyped contributors! (#68)SJIS, EUCJP and JIS (e.g., U+301C (〜) is now converted to 0x8160 in SJIS and 0xA1C1 in EUCJP). (#67)U+301C (〜) being mapped to JIS X 0212 instead of JIS X 0208 when converting to EUCJP and JIS (e.g., 0x8FA1C1 instead of 0xA1C1 in EUCJP). (#67)0x7F being converted as 0x7E instead of falling back to ? on conversion from SJIS. (b848595)feat: add CP932 extensions in SJIS detection and conversion (#65) (Resolves #54, #22)
0xFA40 - 0xFC4B)0xEEF9 to their JIS X 0208 counterpartsU+30F8/U+30F9) in toHiraganaCase and toKatakanaCase by @mahirhir in https://github.com/polygonplanet/encoding.js/pull/62engines.node to >=18.0.0 to match the tested versions (c6008d0)power-assert and uglifyify (4cf36da, 1142dd9)Full Changelog: https://github.com/polygonplanet/encoding.js/compare/2.2.0...2.3.0
SJIS detection and conversion. (#65, #54, #22)
0xFA40 - 0xFC4B).0xEEF9 to their JIS X 0208 counterparts.U+30F8 / U+30F9) in toHiraganaCase and toKatakanaCase. (#62) Thanks @mahirhirEncoding.detect to treat C0 control characters as valid UTF-8. (#64, #49) Thanks @hiros0921engines.node to >=18.0.0 to match the tested versions. (c6008d0)Add fallback: 'ignore' option in Encoding.convert . Thanks #41 , #42 by @syumai
fallback: 'ignore' option in Encoding.convert. Thanks #41, #42 by @syumaifallback: 'error' option in Encoding.convert. #44 by @polygonplanetmocha) to the latest versions by @polygonplanet in (a7bded8)fallback option of convert in README.md (2a522ea)Full Changelog: 2.1.0...2.2.0
fallback: 'ignore' option in Encoding.convert. (#41) Thanks @syumaifallback: 'error' option in Encoding.convert. (#44)mocha) to the latest versions. (a7bded8)fallback option of convert in README.md (2a522ea)Remove output source map encoding.min.js.map from bundles
encoding.min.js.map from bundles (b963656).travis.yml) to GitHub Actions (.github/workflows/ci.yml) by @polygonplanet in (8c4612e)eslint, mocha, uglify-js) to the latest versions by @polygonplanet in (f092635)detect, convert, urlEncode/urlDecode, base64Encode/base64Decode, codeToString/stringToCode, Japanese Zenkaku/Hankaku conversion) in README.md.Full Changelog: 2.0.0...2.1.0
encoding.min.js.map from bundles to simplify build and reduce distribution size. (b963656).travis.yml) to GitHub Actions (.github/workflows/ci.yml). (8c4612e)eslint, mocha, uglify-js) to the latest versions. (f092635)detect,
convert,
urlEncode/urlDecode,
base64Encode/base64Decode,
codeToString/stringToCode,
Japanese Zenkaku/Hankaku conversion
) in README.md.Fix deprecated Buffer constructor by @polygonplanet in
fallback option to Encoding.convert (5622bfa) Thanks #23 by @tohutohu, fallback types by @p-chanEncoding.version (bd3d6ef)bower support (981ea39)Full Changelog: 1.0.30...2.0.0
Fix bug for can't find module by @polygonplanet in #9
Full Changelog: 1.0.29...1.0.30
Full Changelog: https://github.com/polygonplanet/encoding.js/compare/1.0.29...1.0.30
Fix can't find module in using 'require'.
Drop Gruntfile.js and modularize the code base by browserify.
Gruntfile.js and modularize the code base by browserify.Fix the grammar in README.md (#4) Thanks @iku000888
Fix argument decision of the detect method (#3) Thanks @spring-raining
Add base64Encode and base64Decode
base64Encode and base64Decode (729bb4f)Fix internal isObject() method for old IE browsers (#2) (32f6c02) Thanks @dmitrygorbenko
isObject() method for old IE browsers (#2) (32f6c02) Thanks @dmitrygorbenko### Features * Add bower.json
Optimize process speed of urlEncode.
urlEncode. (b5f16d4)* No API changes.
One column per quarter.