htmlize
Correctly encode and decode HTML entities in UTF-8
1.1.0
4.5M downloads/mo
#4758 most downloaded on crates.io
danielparks/htmlize
What this package is like to depend on
Last release 4 months ago
13 Apr 2026
Release timing varies
gaps range from 3 weeks to 3.0 years
Most releases are documented
notes for 9 of 11 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
11 releases · first in 2019
1 release in the last 12 months
see the full history below
Release timeline
11 releases · Dec 2019 to Apr 2026Releases
latest 11-
1.1.013 Apr 2026Release notes
Open source →- Major performance improvements when unescaping text in many cases (for both the
unescapeandunescape_fastfeatures). - Major improvements in build time for the
unescape_fastfeatures (went from 8 seconds to 3 seconds on my laptop). - Add
BARE_ENTITY_MAX_LENGTHconstant that contains the length of the longest entity without a semicolon (enabled with featureentities). - Clarify examples in documentation and README.
- Fix a few spelling mistakes in documentation.
Security
- RUSTSEC-2026-0097: the rand crate was unsound in certain circumstances. Htmlize depends on rand via phf and couldn’t trigger the unsoundness on its own. Thanks to MarkusPettersson98 for the PR!
Release notes
Open source →- Major performance improvements when unescaping text in many cases (for both
the
unescapeandunescape_fastfeatures). - Major improvements in build time for the
unescape_fastfeatures (went from 8 seconds to 3 seconds on my laptop). - Add
BARE_ENTITY_MAX_LENGTHconstant that contains the length of the longest entity without a semicolon (enabled with featureentities). - Clarify examples in documentation and README.
- Fix a few spelling mistakes in documentation.
Security
- RUSTSEC-2026-0097: the rand crate was unsound in certain circumstances. Htmlize depends on rand via phf and couldn’t trigger the unsoundness on its own. Thanks to MarkusPettersson98 for the PR!
- Major performance improvements when unescaping text in many cases (for both the
-
1.0.627 Apr 2025Release notes
Open source →Release notes
Open source → -
1.0.515 Mar 2024Release notes
Open source →- Exclude more files from final package to significantly reduce package size.
Release notes
Open source →- Exclude more files from final package to significantly reduce package size.
-
1.0.419 Feb 2024Release notes
Open source →- Hide usage of assert2 in doc examples to make them slightly clearer for users not familiar with it.
Security fixes
- Upgrade indirect dependency rustix to fix a security vulnerability in directory iterators. This does not affect htmlize, since rustix is only used by development dependencies.
Release notes
Open source →- Hide usage of assert2 in doc examples to make them slightly clearer for users not familiar with it.
Security fixes
- Upgrade indirect dependency rustix to fix a security vulnerability in directory iterators. This does not affect htmlize, since rustix is only used by development dependencies.
-
1.0.310 Jul 2023Release notes
Open source →- Enabled feature marks on docs.rs to make it clearer what features are required by what functions.
- Clarified ownership and licensing of entities.json data file.
Release notes
Open source →- Enabled feature marks on docs.rs to make it clearer what features are required by what functions.
- Clarified ownership and licensing of entities.json data file.
-
1.0.204 Mar 2023Release notes
Open source →- Fix building with
unescapefeature but notunescape_fast. Added tests for
a few common feature flags — in addition to--all-features— to the CI check
to avoid this sort of problem in the future.
Release notes
Open source →- Fix building with
unescapefeature but notunescape_fast. Added tests for a few common feature flags — in addition to--all-features— to the CI check to avoid this sort of problem in the future.
- Fix building with
-
1.0.104 Mar 2023 -
1.0.004 Mar 2023Release notes
Open source →Breaking changes
- Hid
unescape()behindunescapefeature. This allows users to avoid the
dependency on phf and the build dependency on serde_json, which cuts build
times on my machine by more than 90% (from 6.2 seconds to 0.5 seconds). - Hid
ENTITIESbehindentitiesfeatures for the same reason I added the
unescapefeature. Note that theunescapefeature automatically enables
theentitiesfeature, butunescape_fasterdoes not. - Switched both escape and unescape functions to use
Cow<'a, str>for input
and output. This allows for significant performance improvements when the
input can be returned unchanged. - Updated minimum supported Rust version (MSRV) to 1.60.
Improvements
- Significantly optimized both escape and unescape functions. Many of the
improvements to the escape functions are similar to the ones outlined in Lise
Henry’s excellent post on optimizing HTML entity escaping
(see also: its Reddit discussion), though most notably I’m
using memchr directly rather than regex. - Added
unescape_fasterfeature for even faster unescaping at the cost of
longer build times (about 30 seconds longer on my machine). - Added
unescape_attribute()to handle the special rules for dealing with
entities in the value of an HTML attribute. Also addsunescape_in(), which
takes a context parameter that can either beContext::Attributeor
Context::General(for everything else). - Added
unescape_bytes_in()to work on[u8]rather thanstr. - Added
escape_..._bytes()functions to work on[u8]rather thanstr. - Switched to the phf_codegen crate instead of using the
phf_map!macro.
On my machine, this cuts build time by about 25% (~2 seconds). - Clarified documentation of
ENTITIESto indicate that it’s aMap, not just
a collection of tuples.
Bug fixes
-
unescape()incorrectly outputted the replacement character (U+FFFD “�”) for
certain numeric entities:- Noncharacters
- Control characters
0x0D(carriage return)
A close reading of the spec and some browser testing shows that behavior to
be incorrect. Those characters are now outputted as themselves. -
unescape()incorrectly outputted long numeric entities as the literal text
of the entity.A close reading of the spec and some browser testing shows that behavior to
be incorrect. Those long entities are now outputted as the replacement
character (U+FFFD “�”).
Release notes
Open source →Breaking changes
- Hid
unescape()behindunescapefeature. This allows users to avoid the dependency on phf and the build dependency on serde_json, which cuts build times on my machine by more than 90% (from 6.2 seconds to 0.5 seconds). - Hid
ENTITIESbehindentitiesfeatures for the same reason I added theunescapefeature. Note that theunescapefeature automatically enables theentitiesfeature, butunescape_fasterdoes not. - Switched both escape and unescape functions to use
Cow<'a, str>for input and output. This allows for significant performance improvements when the input can be returned unchanged. - Updated minimum supported Rust version (MSRV) to 1.60.
Improvements
- Significantly optimized both escape and unescape functions. Many of the improvements to the escape functions are similar to the ones outlined in Lise Henry’s excellent post on optimizing HTML entity escaping (see also: its Reddit discussion), though most notably I’m using memchr directly rather than regex.
- Added
unescape_fasterfeature for even faster unescaping at the cost of longer build times (about 30 seconds longer on my machine). - Added
unescape_attribute()to handle the special rules for dealing with entities in the value of an HTML attribute. Also addsunescape_in(), which takes a context parameter that can either beContext::AttributeorContext::General(for everything else). - Added
unescape_bytes_in()to work on[u8]rather thanstr. - Added
escape_..._bytes()functions to work on[u8]rather thanstr. - Switched to the phf_codegen crate instead of using the
phf_map!macro. On my machine, this cuts build time by about 25% (~2 seconds). - Clarified documentation of
ENTITIESto indicate that it’s aMap, not just a collection of tuples.
Bug fixes
-
unescape()incorrectly outputted the replacement character (U+FFFD “�”) for certain numeric entities:- Noncharacters
- Control characters
0x0D(carriage return)
A close reading of the spec and some browser testing shows that behavior to be incorrect. Those characters are now outputted as themselves.
-
unescape()incorrectly outputted long numeric entities as the literal text of the entity.A close reading of the spec and some browser testing shows that behavior to be incorrect. Those long entities are now outputted as the replacement character (U+FFFD “�”).
- Hid
-
0.5.113 Dec 2022 -
0.5.018 Dec 2019Nothing published for this version
-
0.1.012 Dec 2019Nothing published for this version