The inverse of _.escape. Converts the HTML entities &, <, >, ", and ' back to &, <, >, ", and '. Part of Lodash String (stable since 0.6.0 — not deprecated). Note: no other HTML entities are unescaped — use a library like he for fuller decoding.
Pass the string and options shown below. Check the return type before you chain another helper.
Syntax
Call _.unescape. Start with this line.
Lodash
_.unescape([string=''])
Call
What it does
_.unescape([string=''])
Primary signature.
_.unescape(string)
Transform or inspect a string.
Prefer import unescape from "lodash/unescape" when you want a smaller bundle.
var raw = "Tom & Jerry <3";
var escaped = _.escape(raw);
var back = _.unescape(escaped);
console.log(escaped);
// 'Tom & Jerry <3'
console.log(back);
// 'Tom & Jerry <3'
console.log(back === raw); // true
_.unescape is a Lodash String helper available since 0.6.0. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.x
_.unescape()
Available in [email protected] full builds and the lodash/unescape modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.unescapeSince 0.6.0
Bottom line: Safe for production once Lodash is on the page. Prefer import unescape from "lodash/unescape" for smaller builds. For full HTML entity decoding, use a dedicated library such as he.
Frequently Asked Questions
_.unescape([string='']) converts the HTML entities &, <, >, ", and ' back to &, <, >, ", and '. Official: _.unescape('fred, barney, & pebbles') → 'fred, barney, & pebbles'.
Yes. _.escape encodes those five characters; _.unescape decodes those five entities.