{"name":"entities","version":"8.0.0","description":"Encode & decode XML and HTML entities with ease & speed","keywords":["html entities","entity decoder","entity encoding","html decoding","html encoding","xml decoding","xml encoding"],"repository":{"type":"git","url":"git+https://github.com/fb55/entities.git"},"funding":"https://github.com/fb55/entities?sponsor=1","license":"BSD-2-Clause","author":{"name":"Felix Boehm","email":"me@feedic.com"},"sideEffects":false,"type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./decode":{"types":"./dist/decode.d.ts","default":"./dist/decode.js"},"./escape":{"types":"./dist/escape.d.ts","default":"./dist/escape.js"}},"main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"benchmark":"node --import=tsx scripts/benchmark.ts","build":"tsc","build:docs":"typedoc --hideGenerator src/index.ts","build:encode-trie":"node --import=tsx scripts/write-encode-map.ts","build:trie":"node --import=tsx scripts/write-decode-map.ts","format":"npm run format:es && npm run format:biome","format:biome":"biome check --fix .","format:es":"npm run lint:es -- --fix","lint":"npm run lint:es && npm run lint:ts && npm run lint:biome","lint:biome":"biome check .","lint:es":"eslint .","lint:ts":"tsc --noEmit","prepublishOnly":"npm run build","test":"npm run test:vi && npm run lint","test:vi":"vitest run"},"devDependencies":{"@biomejs/biome":"^2.4.7","@eslint/compat":"^2.0.3","@feedic/eslint-config":"^0.3.1","@types/he":"^1.2.3","@types/node":"^25.5.0","eslint":"^10.0.3","eslint-config-biome":"^2.1.3","globals":"^17.4.0","he":"^1.2.0","html-entities":"^2.6.0","parse-entities":"^4.0.2","tinybench":"^6.0.0","tsx":"^4.21.0","typedoc":"^0.28.17","typescript":"^5.9.3","typescript-eslint":"^8.57.1","vitest":"^4.0.17"},"engines":{"node":">=20.19.0"},"gitHead":"2322ee76c431b990facb259b61b9ff4eb89ef3c9","_id":"entities@8.0.0","bugs":{"url":"https://github.com/fb55/entities/issues"},"homepage":"https://github.com/fb55/entities#readme","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA==","shasum":"c1df5fe3602429747fa233d0dd26f142f0ce4743","tarball":"http://registry-npm.ywwl.com/entities/download/entities-8.0.0.tgz","fileCount":58,"unpackedSize":236002,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/entities@8.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC3uX2TRAeCk8IyaHlOaokfO5vEqi52Qor5NKHfAmVPpQIgHhNwCUJBXnhTye851CXMPD7hOsS7jdZI+1qDIiqw+aM="}],"size":86968,"noattachment":false,"key":"/entities/-/entities-8.0.0.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9191d3f6-c47f-4f03-a389-9d3e9da1759c"}},"directories":{},"maintainers":[{"name":"fb55","email":"me@feedic.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/entities_8.0.0_1773748065315_0.27926214668122373"},"_hasShrinkwrap":false,"readme":"# entities [![NPM version](https://img.shields.io/npm/v/entities.svg)](https://npmjs.org/package/entities) [![Downloads](https://img.shields.io/npm/dm/entities.svg)](https://npmjs.org/package/entities) [![Node.js CI](https://github.com/fb55/entities/actions/workflows/nodejs-test.yml/badge.svg)](https://github.com/fb55/entities/actions/workflows/nodejs-test.yml)\n\nEncode & decode HTML & XML entities with ease & speed.\n\n## Features\n\n- 😇 Tried and true: `entities` is used by many popular libraries; eg.\n  [`htmlparser2`](https://github.com/fb55/htmlparser2), the official\n  [AWS SDK](https://github.com/aws/aws-sdk-js-v3) and\n  [`commonmark`](https://github.com/commonmark/commonmark.js) use it to process\n  HTML entities.\n- ⚡️ Fast: `entities` is the fastest library for decoding HTML entities (as of\n  September 2025); see [performance](#performance).\n- 🎛 Configurable: Get an output tailored for your needs. You are fine with\n  UTF8? That'll save you some bytes. Prefer to only have ASCII characters? We\n  can do that as well!\n\n## How to…\n\n### …install `entities`\n\n    npm install entities\n\n### …use `entities`\n\n```javascript\nimport * as entities from \"entities\";\n\n// Encoding\nentities.escapeUTF8(\"&#38; ü\"); // \"&amp;#38; ü\"\nentities.encodeXML(\"&#38; ü\"); // \"&amp;#38; &#xfc;\"\nentities.encodeHTML(\"&#38; ü\"); // \"&amp;&num;38&semi; &uuml;\"\n\n// Decoding\nentities.decodeXML(\"asdf &amp; &#xFF; &#xFC; &apos;\"); // \"asdf & ÿ ü '\"\nentities.decodeHTML(\"asdf &amp; &yuml; &uuml; &apos;\"); // \"asdf & ÿ ü '\"\n```\n\n## Performance\n\nBenchmarked in September 2025 with Node v24.6.0 on Apple M2 using `tinybench`.\nHigher ops/s is better; `avg (μs)` is the mean time per operation.\nSee `scripts/benchmark.ts` to reproduce.\n\n### Decoding\n\n| Library        | Version | ops/s     | avg (μs) | ±%   | slower |\n| -------------- | ------- | --------- | -------- | ---- | ------ |\n| entities       | 7.0.0   | 5,838,416 | 175.57   | 0.06 | —      |\n| html-entities  | 2.6.0   | 2,919,637 | 347.77   | 0.33 | 50.0%  |\n| he             | 1.2.0   | 2,318,438 | 446.48   | 0.70 | 60.3%  |\n| parse-entities | 4.0.2   |   852,855 | 1,199.51 | 0.36 | 85.4%  |\n\n### Encoding\n\n| Library        | Version | ops/s     | avg (μs) | ±%   | slower |\n| -------------- | ------- | --------- | -------- | ---- | ------ |\n| entities       | 7.0.0   | 2,770,115 | 368.09   | 0.11 | —      |\n| html-entities  | 2.6.0   | 1,491,963 | 679.96   | 0.58 | 46.2%  |\n| he             | 1.2.0   |   481,278 | 2,118.25 | 0.61 | 82.6%  |\n\n### Escaping\n\n| Library        | Version | ops/s     | avg (μs) | ±%   | slower |\n| -------------- | ------- | --------- | -------- | ---- | ------ |\n| entities       | 7.0.0   | 4,616,468 | 223.84   | 0.17 | —      |\n| he             | 1.2.0   | 3,659,301 | 280.76   | 0.58 | 20.7%  |\n| html-entities  | 2.6.0   | 3,555,301 | 296.63   | 0.84 | 23.0%  |\n\nNote: Micro-benchmarks may vary across machines and Node versions.\n\n---\n\n## FAQ\n\n> What methods should I actually use to encode my documents?\n\nIf your target supports UTF-8, the `escapeUTF8` method is going to be your best\nchoice. Otherwise, use either `encodeHTML` or `encodeXML` based on whether\nyou're dealing with an HTML or an XML document.\n\nYou can have a look at the options for the `encode` and `decode` methods to see\neverything you can configure.\n\n> When should I use strict decoding?\n\nWhen strict decoding, entities not terminated with a semicolon will be ignored.\nThis is helpful for decoding entities in legacy environments.\n\n> Why should I use `entities` instead of alternative modules?\n\nAs of September 2025, `entities` is faster than other modules. Still, this is\nnot a differentiated space and other modules can catch up.\n\n**More importantly**, you might already have `entities` in your dependency graph\n(as a dependency of eg. `cheerio`, or `htmlparser2`), and including it directly\nmight not even increase your bundle size. The same is true for other entity\nlibraries, so have a look through your `node_modules` directory!\n\n> Does `entities` support tree shaking?\n\nYes! Note that for best results, you should not use the `encode` and `decode`\nfunctions, as they wrap around a number of other functions, all of which will\nremain in the bundle. Instead, use the functions that you need directly.\n\n---\n\n## Acknowledgements\n\nThis library wouldn't be possible without the work of these individuals. Thanks\nto\n\n- [@mathiasbynens](https://github.com/mathiasbynens) for his explanations about\n  character encodings, and his library `he`, which was one of the inspirations\n  for `entities`\n- [@inikulin](https://github.com/inikulin) for his work on optimized tries for\n  decoding HTML entities for the `parse5` project\n- [@mdevils](https://github.com/mdevils) for taking on the challenge of\n  producing a quick entity library with his `html-entities` library. `entities`\n  would be quite a bit slower if there wasn't any competition. Right now\n  `entities` is on top, but we'll see how long that lasts!\n\n---\n\nLicense: BSD-2-Clause\n\n## Security contact information\n\nTo report a security vulnerability, please use the\n[Tidelift security contact](https://tidelift.com/security). Tidelift will\ncoordinate the fix and disclosure.\n","publish_time":1773748065464,"_cnpm_publish_time":1773748065464,"dist-tags":{"latest":"9.0.0"}}