{"id":13469668,"url":"https://github.com/fb55/entities","last_synced_at":"2026-01-21T15:08:01.231Z","repository":{"id":37664837,"uuid":"3172629","full_name":"fb55/entities","owner":"fb55","description":"encode \u0026 decode HTML \u0026 XML entities with ease \u0026 speed","archived":false,"fork":false,"pushed_at":"2025-05-06T20:40:00.000Z","size":5031,"stargazers_count":338,"open_issues_count":6,"forks_count":64,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-06T21:35:39.044Z","etag":null,"topics":["entities","html-entities","javascript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fb55.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["fb55"],"tidelift":"npm/entities"}},"created_at":"2012-01-13T17:02:59.000Z","updated_at":"2025-05-06T20:38:50.000Z","dependencies_parsed_at":"2023-02-13T02:40:24.147Z","dependency_job_id":"bfd6bae9-c0d1-42e5-a98d-8bef9e8deb0d","html_url":"https://github.com/fb55/entities","commit_stats":{"total_commits":1562,"total_committers":22,"mean_commits":71.0,"dds":"0.32330345710627406","last_synced_commit":"c44b01c7ae7ba0b5f3d1190ec7cd89f120e3d227"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2Fentities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2Fentities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2Fentities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2Fentities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fb55","download_url":"https://codeload.github.com/fb55/entities/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252892503,"owners_count":21820648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["entities","html-entities","javascript"],"created_at":"2024-07-31T15:01:49.839Z","updated_at":"2026-01-21T15:08:01.223Z","avatar_url":"https://github.com/fb55.png","language":"TypeScript","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 \u0026 decode HTML \u0026 XML entities with ease \u0026 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\nconst entities = require(\"entities\");\n\n// Encoding\nentities.escapeUTF8(\"\u0026#38; ü\"); // \"\u0026amp;#38; ü\"\nentities.encodeXML(\"\u0026#38; ü\"); // \"\u0026amp;#38; \u0026#xfc;\"\nentities.encodeHTML(\"\u0026#38; ü\"); // \"\u0026amp;\u0026num;38\u0026semi; \u0026uuml;\"\n\n// Decoding\nentities.decodeXML(\"asdf \u0026amp; \u0026#xFF; \u0026#xFC; \u0026apos;\"); // \"asdf \u0026 ÿ ü '\"\nentities.decodeHTML(\"asdf \u0026amp; \u0026yuml; \u0026uuml; \u0026apos;\"); // \"asdf \u0026 ÿ ü '\"\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\u003e 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\u003e 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\u003e 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\u003e Does `entities` support tree shaking?\n\nYes! `entities` ships as both a CommonJS and a ES module. Note that for best\nresults, you should not use the `encode` and `decode` functions, as they wrap\naround a number of other functions, all of which will remain in the bundle.\nInstead, 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\n## `entities` for enterprise\n\nAvailable as part of the Tidelift Subscription\n\nThe maintainers of `entities` and thousands of other packages are working with\nTidelift to deliver commercial support and maintenance for the open source\ndependencies you use to build your applications. Save time, reduce risk, and\nimprove code health, while paying the maintainers of the exact dependencies you\nuse.\n[Learn more.](https://tidelift.com/subscription/pkg/npm-entities?utm_source=npm-entities\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo)\n","funding_links":["https://github.com/sponsors/fb55","https://tidelift.com/funding/github/npm/entities","https://tidelift.com/security","https://tidelift.com/subscription/pkg/npm-entities?utm_source=npm-entities\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo"],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffb55%2Fentities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffb55%2Fentities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffb55%2Fentities/lists"}