> For AI agents: the complete documentation index is available at https://massaman.dev/llms.txt, the full documentation bundle is available at https://massaman.dev/llms-full.txt.

# unescape es-toolkit

Converts HTML entity characters to their original characters.

```typescript
const result = unescape(str);
```

## Usage

### `unescape(str)`

Use `unescape` when you want to convert HTML entity characters back to their original characters. It converts HTML entities like `&amp;`, `&lt;`, `&gt;`, `&quot;`, `&#39;` to `&`, `<`, `>`, `"`, `'` characters. This is the inverse operation of the [`escape`](https://massaman.dev/reference/string/escape.md) function.

```typescript
import { unescape } from 'es-toolkit/string';

// Convert HTML tag entities to original characters
unescape('This is a &lt;div&gt; element.');
// Returns: 'This is a <div> element.'

// Convert quote entities to original characters
unescape('This is a &quot;quote&quot;');
// Returns: 'This is a "quote"'

// Convert single quote entities to original characters
unescape('This is a &#39;quote&#39;');
// Returns: 'This is a 'quote''

// Convert ampersand entities to original characters
unescape('This is a &amp; symbol');
// Returns: 'This is a & symbol'
```

Useful when processing data from HTML forms or URLs:

```typescript
// Convert HTML entities from user input
const userInput = 'My favorite tag is &lt;button&gt;';
const converted = unescape(userInput);
console.log(converted); // 'My favorite tag is <button>'

// Can also convert strings with mixed entities
const mixed = '&quot;Hello &amp; Welcome&quot; &lt;says the &gt; user';
const result = unescape(mixed);
console.log(result); // '"Hello & Welcome" <says the > user'
```

#### Parameters


strstringrequired

The string to convert.

#### Returns

Returns a string with HTML entities converted to their original characters.

```typescript
string
```


Source: es-toolkit

Re-exported verbatim from [`es-toolkit`](https://es-toolkit.dev/reference/string/unescape.html). Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.
