# discord-markdown-parser

> Parse discord-style markdown into an abstract syntax tree.

Latest version **1.3.1** (published 2025-12-23) · Apache License license · 0 weekly downloads

## Install

```sh
npm install discord-markdown-parser
pnpm add discord-markdown-parser
yarn add discord-markdown-parser
bun add discord-markdown-parser
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2025-12-23 |
| First published | 2022-09-17 |
| Weekly downloads | 0 |
| License | Apache License |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 111.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 48 |
| Author | Derock |
| Maintainers | derockdev |
| Keywords | discord, markdown, parser, discord-markdown-parser, discord-markdown, simple-markdown, discord-parser |

## Links

- npm: https://www.npmjs.com/package/discord-markdown-parser
- Repository: https://github.com/ItzDerock/discord-markdown-parser
- Issues: https://github.com/ItzDerock/discord-markdown-parser/issues
- npm.io page: https://npm.io/package/discord-markdown-parser

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.3.1 (latest) — 2025-12-23
- 1.3.0 — 2025-12-22
- 1.2.0 — 2025-01-30
- 1.1.0 — 2022-09-27
- 1.0.1 — 2022-09-19
- 1.0.0 — 2022-09-17

## README

# `discord-markdown-parser`

[![Discord](https://img.shields.io/discord/555474311637499955?label=discord)](https://discord.gg/rf5qN7C)
[![npm](https://img.shields.io/npm/dw/discord-markdown-parser)](http://npmjs.org/package/discord-markdown-parser)
![GitHub package.json version](https://img.shields.io/github/package-json/v/ItzDerock/discord-markdown-parser)
![GitHub Repo stars](https://img.shields.io/github/stars/ItzDerock/discord-markdown-parser?style=social)

A node.js markdown implementation based on the [simple-markdown](https://github.com/Khan/simple-markdown) library, which is the same technology [discord use](https://discord.com/blog/how-discord-renders-rich-messages-on-the-android-app).

Designed to be used for [discord-html-transcripts](https://github.com/ItzDerock/discord-html-transcripts)

`discord-markdown-parser` will parse any given string into an [AST tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) and supports:

- links
- block quotes
- inline quotes
- code blocks
- inline code
- italics (em)
- spoilers
- timestamps
- bold
- strikethrough
- underline
- channel mentions
- user mentions
- role mentions
- @everyone
- @here
- emojis
- slash command mentions
- guild navigation mentions
- & more

## Usage

```js
import { parse } from 'discord-markdown-parser';
// or const { parse } = require('discord-markdown-parser');

// input is a string
const input = 'test **markdown** with `cool` *stuff*';

// specify what type of markdown this is
// this can be 'normal' or 'extended' (default = normal)
// extended should be used if the input is from a webhook message or embed description.
const type = 'normal';

// will return an AST tree
const parsed = parse(input, type);
```

## Extending

```js
// you can import the default rules using
import { SimpleMarkdown, rules } from 'discord-markdown-parser';

// and you can add your own rules
const newRules = {
    ...rules,
    customRule: {
        ...
    } // see simple-markdown documentation for details
};

// and create the parser
const parser = SimpleMarkdown.parserFor(newRules);
```

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