# @types/turndown

> TypeScript definitions for turndown

Latest version **5.0.6** (published 2025-10-26) · MIT license · 3.0M weekly downloads

## Install

```sh
npm install @types/turndown
pnpm add @types/turndown
yarn add @types/turndown
bun add @types/turndown
```

## Health

**Score 90/100 (A)** — status: stable.

Positive: high downloads; has types; no vulnerabilities; high maintenance score; inferred trend; popular repo; extremely popular.

Warnings: no esm support.

## Facts

| | |
|---|---|
| Version | 5.0.6 |
| Published | 2025-10-26 |
| First published | 2019-03-01 |
| Weekly downloads | 3.0M |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51438 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/turndown
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/turndown
- npm.io page: https://npm.io/package/@types/turndown

## Recent versions

- 5.0.6 (latest) — 2025-10-26
- 5.0.5 (ts5.0) — 2024-07-23
- 5.0.4 (ts4.6) — 2023-11-07
- 5.0.2 (ts4.3) — 2023-09-12
- 5.0.1 (ts4.0) — 2021-07-02
- 5.0.0 (ts3.3) — 2019-03-01
- 5.0.3 — 2023-10-18

## README

# Installation
> `npm install --save @types/turndown`

# Summary
This package contains type definitions for turndown (https://github.com/domchristie/turndown).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/turndown.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/turndown/index.d.ts)
````ts
declare class TurndownService {
    constructor(options?: TurndownService.Options);

    addRule(key: string, rule: TurndownService.Rule): this;
    keep(filter: TurndownService.Filter): this;
    remove(filter: TurndownService.Filter): this;
    use(plugins: TurndownService.Plugin | TurndownService.Plugin[]): this;
    escape(str: string): string;

    turndown(html: string | TurndownService.Node): string;

    options: TurndownService.Options;
    rules: TurndownService.Rules;
}

export = TurndownService;

declare namespace TurndownService {
    interface Options {
        headingStyle?: "setext" | "atx" | undefined;
        hr?: string | undefined;
        br?: string | undefined;
        bulletListMarker?: "-" | "+" | "*" | undefined;
        codeBlockStyle?: "indented" | "fenced" | undefined;
        emDelimiter?: "_" | "*" | undefined;
        fence?: "```" | "~~~" | undefined;
        strongDelimiter?: "__" | "**" | undefined;
        linkStyle?: "inlined" | "referenced" | undefined;
        linkReferenceStyle?: "full" | "collapsed" | "shortcut" | undefined;
        preformattedCode?: boolean;

        keepReplacement?: ReplacementFunction | undefined;
        blankReplacement?: ReplacementFunction | undefined;
        defaultReplacement?: ReplacementFunction | undefined;
    }

    interface Rule {
        filter: Filter;
        replacement?: ReplacementFunction | undefined;
    }

    interface Rules {
        options: Options;
        array: Rule[];

        blankRule: ReplacementFunction;
        defaultRule: ReplacementFunction;
        keepReplacement: ReplacementFunction;

        add(key: Filter, rule: Rule): void;
        forEach(callback: (rule: Rule, index: number) => any): void;
        forNode(node: HTMLElement): Rule;
        keep(filter: Filter): void;
        remove(filter: Filter): void;
    }

    type Plugin = (service: TurndownService) => void;
    type Node = HTMLElement | Document | DocumentFragment;

    type Filter = TagName | TagName[] | FilterFunction;
    type FilterFunction = (node: HTMLElement, options: Options) => boolean;

    type ReplacementFunction = (
        content: string,
        node: HTMLElement,
        options: Options,
    ) => string;

    type TagName = keyof HTMLElementTagNameMap;
}

````

### Additional Details
 * Last updated: Sun, 26 Oct 2025 17:33:29 GMT
 * Dependencies: none

# Credits
These definitions were written by [Sergey Zhidkov](https://github.com/sergey-zhidkov).

---
_Source: https://npm.io/package/@types/turndown · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
