{"_id":"entities@8.1.0","bugs":{"url":"https://github.com/fb55/entities/issues"},"dist":{"shasum":"9632d69619ebdbe0cf0ef22f53088fe5a2163d86","tarball":"http://registry-npm.ywwl.com/entities/download/entities-8.1.0.tgz","fileCount":53,"integrity":"sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==","signatures":[{"sig":"MEUCIQCCqfhQdarXml1XbnfxhvIO5EABzUNqGx5SN7EQYscZHAIgeZg3TBbD/sCJ0QOuHbfe+zEtC1dWlMrO8dUb88/JOdE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDQoki/FcVla2Wi12EW5XdjIIl4FgvwPl76BUWPlXWsKwIgbR4m3rowuFam1WRndTqViQIMjNE0coWetJvWG1sH1dc="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/entities@8.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":330191,"size":100412,"noattachment":false,"key":"/entities/-/entities-8.1.0.tgz"},"main":"./dist/index.js","name":"entities","type":"module","types":"./dist/index.d.ts","author":{"name":"Felix Boehm","email":"me@feedic.com"},"engines":{"node":">=20.19.0"},"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"}},"funding":"https://github.com/fb55/entities?sponsor=1","gitHead":"c71f5625c6bb604c63fb62ff500736b4563c4c00","license":"BSD-2-Clause","scripts":{"lint":"npm run lint:es && npm run lint:ts && npm run lint:biome","test":"npm run test:vi && npm run lint","build":"tsc","format":"npm run format:es && npm run format:biome","lint:es":"eslint .","lint:ts":"tsc --noEmit -p tsconfig.eslint.json","test:vi":"vitest run","benchmark":"node --import=tsx scripts/benchmark.ts","format:es":"npm run lint:es -- --fix","build:docs":"typedoc --hideGenerator src/index.ts","build:trie":"node --import=tsx scripts/write-decode-map.ts","lint:biome":"biome check .","format:biome":"biome check --fix .","prepublishOnly":"npm run build","build:encode-trie":"node --import=tsx scripts/write-encode-map.ts"},"version":"8.1.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9191d3f6-c47f-4f03-a389-9d3e9da1759c"}},"homepage":"https://github.com/fb55/entities#readme","keywords":["html entities","entity decoder","entity encoding","html decoding","html encoding","xml decoding","xml encoding"],"repository":{"url":"git+https://github.com/fb55/entities.git","type":"git"},"_npmVersion":"11.19.0","description":"Encode & decode XML and HTML entities with ease & speed","directories":{},"maintainers":[{"name":"fb55","email":"me@feedic.com"}],"sideEffects":false,"_nodeVersion":"24.20.0","_hasShrinkwrap":false,"devDependencies":{"he":"^1.2.0","tsx":"^4.23.13","eslint":"^10.10.0","vitest":"^5.0.0","globals":"^17.12.0","typedoc":"^0.28.20","@types/he":"^1.2.3","tinybench":"^6.1.5","typescript":"^6.0.3","@types/node":"^26.4.1","html-entities":"^2.6.0","@biomejs/biome":"^2.5.12","@eslint/compat":"^2.1.1","parse-entities":"^4.0.2","typescript-eslint":"^8.69.0","eslint-config-biome":"^2.1.3","@feedic/eslint-config":"^0.5.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/entities_8.1.0_1788820924864_0.22051975369626398"},"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":1788820924929,"_cnpm_publish_time":1788820924929,"dist-tags":{"latest":"9.0.0"}}