Skip to main content
Home

@std/html@1.0.4
Built and signed on GitHub Actions

Functions for HTML, such as escaping or unescaping HTML entities

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
3 weeks ago (1.0.4)
function unescape
unescape(
str: string,
options?: Partial<UnescapeOptions>,
): string

Unescapes HTML entities in text.

Default options only handle &<>'" and numeric entities.

Examples

Basic usage

import { unescape } from "@std/html/entities";
import { assertEquals } from "@std/assert";

assertEquals(unescape("&lt;&gt;&#39;&amp;AA"), "<>'&AA");
assertEquals(unescape("&thorn;&eth;"), "&thorn;&eth;");

Using a custom entity list

This uses the full named entity list from the HTML spec (~47K un-minified)

import { unescape } from "@std/html/entities";
import entityList from "@std/html/named-entity-list.json" with { type: "json" };
import { assertEquals } from "@std/assert";

assertEquals(unescape("&lt;&gt;&#39;&amp;AA", { entityList }), "<>'&AA");

Parameters

The string to unescape.

optional
options: Partial<UnescapeOptions>

Options for unescaping.

Return Type

The unescaped string.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/html

Import symbol

import { unescape } from "@std/html/entities";
or

Import directly with a jsr specifier

import { unescape } from "jsr:@std/html/entities";

Add Package

pnpm i jsr:@std/html
or (using pnpm 10.8 or older)
pnpm dlx jsr add @std/html

Import symbol

import { unescape } from "@std/html/entities";

Add Package

yarn add jsr:@std/html
or (using Yarn 4.8 or older)
yarn dlx jsr add @std/html

Import symbol

import { unescape } from "@std/html/entities";

Add Package

vlt install jsr:@std/html

Import symbol

import { unescape } from "@std/html/entities";

Add Package

npx jsr add @std/html

Import symbol

import { unescape } from "@std/html/entities";

Add Package

bunx jsr add @std/html

Import symbol

import { unescape } from "@std/html/entities";