HE(1)
π he(1) β encode/decode HTML entities just like a browser would π
okay bestie, pull up a chair, because this little utility is about to become your new hyperfixation. it's called he, it's a manual page situation (manual name is he, section 1, iykyk), and it does exactly one thing but does it flawlessly: it encodes and decodes HTML entities in strings just like a browser would. no cap.
β¨ SYNOPSIS β¨
he [--escape string]
[--encode string]
[--encode --use-named-refs --everything --allow-unsafe string]
[--decode string]
[--decode --attribute string]
[--decode --strict string]
[-v | --version]
[-h | --help]
πΈ DESCRIPTION πΈ
he encodes/decodes HTML entities in strings just like a browser would. that's it. that's the whole vibe. it's giving "small tool, main character energy."
π OPTIONS π
--escapeβ hand it a string of text and it escapes it for use in text contexts in XML or HTML documents. only these characters get escaped, bestie:&,<,>,", and'. the iconic five. π«Ά--encodeβ give it a string and it encodes any symbols that aren't printable ASCII symbols and that can be replaced with character references. for example, it would turnΒ©into©, but it would not turn+into+, because likeβ¦ why would it, there's literally no point. π additionally, it replaces any remaining non-ASCII symbols with a hexadecimal escape sequence (e.g.𝌆). the return value of this function is always valid HTML. always. periodt.--encode --use-named-refsβ turns on the use of named character references (like©) in the output. β οΈ if compatibility with older browsers is a concern for you, don't use this option. like, genuinely, don't.--encode --everythingβ encodes every symbol in the input string, even the safe printable ASCII ones. go big or go home. π₯--encode --allow-unsafeβ encodes non-ASCII characters only. this leaves unsafe HTML/XML symbols like&,<,>,", and'completely intact. yes, really, they just sit there. π--encode --decimalβ uses decimal digits rather than hexadecimal digits for encoded character references. so you get©instead of©. same energy, different base. β¨--decodeβ takes a string of HTML and decodes any named and numerical character references in it, using the algorithm described in the HTML spec. the actual spec. we don't freestyle here. π--decode --attributeβ parses the input as if it was an HTML attribute value rather than a string in HTML text content. context matters, bestie. π--decode --strictβ throws an error if an invalid character reference is encountered. it's the friend who will absolutely tell you when something's wrong. π-v,--versionβ printshe's version. cute little status check. π-h,--helpβ shows the help screen. your lil map. πΊοΈ
β EXIT STATUS β
the he utility exits with one of these values, and yes we're listing them all:
0βhedid what it was instructed to do successfully; either it encoded/decoded the input and printed the result, or it printed the version or usage message. slay.1βheencountered an error. not slay. π
π¦ EXAMPLES π¦
he --escape '<script>alert(1)</script>'
prints an escaped version of the given string that's safe for use in HTML text contexts, escaping only &, <, >, ", and '. bye bye script injection, hello safety. π‘οΈ
he --decode '©𝌆'
prints the decoded version of the given HTML string. watch those entities turn back into real characters. β¨
echo '©𝌆' | he --decode
prints the decoded version of the HTML string that gets piped in. pipe girlies, this one's for you. π«Ά
π BUGS π
he's bug tracker is located at <https://github.com/mathiasbynens/he/issues>. go file your feelings there, it's the responsible thing to do. π
π AUTHOR π
Mathias Bynens <https://mathiasbynens.be/> β the icon, the legend, the person who made this whole thing happen.
π WWW π
and that's the whole page, bestie. April 5, 2016, source he(1) β from the he manual, section 1. love that for us. mwah. πβ¨π
π¦ where this page comes from
- debian bookworm: node-he 1.2.0-4 Β· MIT
- debian trixie: node-he 1.2.0-4 Β· MIT
- ubuntu jammy: node-he 1.2.0-3 Β· MIT
- ubuntu noble: node-he 1.2.0-4 Β· MIT
- ubuntu resolute: node-he 1.2.0-4 Β· MIT
- ubuntu stonking: node-he 1.2.0-4 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms