he

A robust, spec-compliant HTML entity encoder and decoder for JavaScript with full Unicode support.

Library
npm
v2.0.0
3,612 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
56 /100 Fair
Development Activity 52
Maintenance 12
Community 60
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
73 /100 Good
Architecture 70
Code Quality 75
Innovation 80
Learning Curve 65

he is a robust HTML entity encoder and decoder for JavaScript, implementing the WHATWG HTML specification’s character-reference tokenizing algorithm exactly as a browser would. It correctly handles every standardized named character reference, resolves ambiguous ampersands, and supports astral Unicode code points beyond the basic multilingual plane — edge cases that trip up many simpler entity libraries built on ad-hoc regex tables.

Beyond encode/decode, it exposes lightweight escape/unescape helpers for the narrower set of HTML-unsafe characters, plus a command-line binary for encoding or decoding text directly from the shell. With tens of millions of weekly downloads, it is widely relied upon as a dependency inside larger HTML-processing, scraping, and templating tools rather than used directly by most application authors.

What You Get

  • Spec-accurate encode()/decode() functions covering every named HTML5 character reference
  • Support for astral Unicode symbols (surrogate pairs) that many alternatives mishandle
  • Lightweight escape()/unescape() helpers for the minimal HTML-unsafe character set
  • A he command-line binary for encoding/decoding text from the shell

Common Use Cases

  • Decoding HTML entities scraped or parsed from web pages before further text processing
  • Encoding user-supplied text for safe inclusion in HTML templates
  • Building HTML parsers or validators that need strict, spec-conformant character-reference handling
  • Converting between named and numeric character references in build tooling

Under The Hood

Architecture

he.js is a single-file UMD module (built from src/he.js via Grunt’s template task) exposing encode, decode, escape, unescape, and version on one flat he namespace object — there is no internal layering. The core data tables (encode/decode maps, ASCII/BMP/astral regexes) are generated at build time from JSON files under data/, sourced from the WHATWG entities spec and a scraped copy of the tokenizer states, via scripts/process-data.js, then inlined into the built he.js as literal regex and object definitions. The runtime module itself ships with zero external dependencies; changing the core mapping tables means re-running the Grunt build pipeline rather than editing the generated file directly.

Tech Stack

Plain JavaScript with a UMD wrapper that detects CommonJS, AMD, and browser globals — no transpilation and no runtime dependencies. Build tooling is Grunt, using grunt-template to inject generated data into src/he.js and grunt-shell to fetch the WHATWG entities.json spec, scrape supplementary spec pages with PhantomJS, and regenerate the astral/BMP/ASCII regexes via regenerate/regexgen. Tests run under QUnit (qunitjs/qunit-extras) across Node, PhantomJS, Rhino, Narwhal, and RingoJS. The package is published to npm, Bower, and Component, and ships a bin/he CLI plus a man/he.1 man page.

Code Quality

tests/tests.js is a single ~6,700-line QUnit suite exercising every entity, edge case (ambiguous ampersands, astral symbols, invalid code points), and option combination across encode/decode/escape/unescape. Historical CI (Travis) ran the suite across multiple JS engines via dedicated Gruntfile targets (test-node, test-phantomjs, test-rhino, test-narwhal, test-ringo), with Istanbul/Codecov coverage reporting. There is no TypeScript and no linter config; the code is pre-ES6, prototype-style JavaScript with manual hasOwnProperty checks and hand-written iteration helpers rather than native array/object methods, reflecting both its 2013 origins and its goal of running in older or exotic JS runtimes.

API Design The public surface is deliberately tiny — four functions (encode, decode, escape, unescape) plus a version string — with safe-by-default behavior and a documented global-override pattern (he.encode.options.x = ...) for callers who don’t want to pass an options object on every call. Every option (useNamedReferences, allowUnsafeSymbols, isAttributeValue, strict, decimal, encodeEverything) is descriptively named and documented in the README with runnable before/after examples. Getting started requires zero configuration: require('he') and call he.encode() or he.decode() immediately.

Used by 11 apps in this directory

JavaScript
99%
MIT

AnythingLLM

AI Assistants · Automation · Developer Tools

67,496

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
91
Repo Health
78
Technical
65
Dependency
Built with
JavaScript 99%
Updated today
Java
49%
Apache 2.0

ClearFlask

Community · Product Management

450

Open-source feedback management and roadmap tool that lets product teams collect, prioritize, and respond to user input — with AI-powered summarization and full self-hosting control.

View details
82
Repo Health
73
Technical
62
Dependency
Built with
Java 49%
TypeScript 46%
Updated 2 weeks ago
TypeScript
100%
Other

Dub

Analytics · Marketing

24,935

The open-source link attribution platform for short links, conversion tracking, and affiliate programs — powering 100M+ clicks monthly.

View details
81
Repo Health
78
Technical
62
Dependency
Built with
TypeScript 100%
Updated today
TypeScript
72%
AGPL 3.0

Firecrawl

AI Development · Developer Tools

194,745

Turn any website into clean, LLM-ready data with a single API call — no proxy headaches, no scraping complexity.

View details
89
Repo Health
83
Technical
65
Dependency
Built with
TypeScript 72%
Python 12%
Updated today
Ruby
65%
AGPL 3.0

Forem

Blogging · Community

22,807

Open source Ruby on Rails platform for building developer communities with articles, discussions, and social profiles—the same software that powers dev.to.

View details
84
Repo Health
79
Technical
67
Dependency
Built with
Ruby 65%
JavaScript 18%
HTML 13%
Updated today
TypeScript
98%
Other

Kibana

Analytics · Monitoring

21,338

Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.

View details
98
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 98%
Updated today
TypeScript
97%
Other

nango

Authentication · Automation · Developer Tools

12,963

Build product integrations with AI using 800+ APIs — auth, proxy, and TypeScript functions on production-grade infrastructure.

View details
94
Repo Health
85
Technical
67
Dependency
Built with
TypeScript 97%
Updated yesterday
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

40,397

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated today
TypeScript
97%
Other

Rocket.Chat

Team Chat

46,304

The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.

View details
96
Repo Health
79
Technical
63
Dependency
Built with
TypeScript 97%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers