decodeURI() works on URIs (ex: decodeURI("%3C") === "<") not on HTML escape entities (ex: decodeURI("&lt;") === "&lt;"). The only improvement to this is to do it like this : return jQuery('<div>').html(text).text(), assuming jQuery is available.