Convert Markdown to Slack Block Kit JSON
npm install markdown-to-slackConvert Markdown to Slack Block Kit JSON format.
Install and use as command-line tool.
``bash
npm install -g markdown-to-slack
$3
Use as TypeScript/JavaScript library.
`typescript
import { MarkdownToSlack } from './source/module'const markdown =
const messages = MarkdownToSlack.convert(markdown)
console.log(JSON.stringify(messages, null, 2))
`API
-
MarkdownToSlack.convert(markdown: string): SlackMessage[]
- Returns array of Slack messages (split by 50-block limit or tables)Mapping Table
| Markdown | Slack Block Kit | Notes |
|----------|----------------|-------|
|
# Heading 1 | Header Block (auto-split if >150 chars) | H1 with visual separation |
| ## Heading 2 | Header Block (auto-split if >150 chars) | H2 with divider |
| ### Heading 3 | Header Block (auto-split if >150 chars) | H3 as header |
| #### Heading 4-6 | Section (bold) | H4-H6 as bold text |
| bold / __bold__ | Rich Text (bold) | Bold formatting |
| italic / _italic_ | Rich Text (italic) | Italic formatting |
| bold+italic | Rich Text (bold+italic) | Combined formatting |
| _text_ | Rich Text (bold+italic) | Alternative combined format |
| ~~strikethrough~~ | Rich Text (strike) | Double tilde strikethrough |
| ~strikethrough~ | Rich Text (strike) | Single tilde strikethrough |
| code | Rich Text (code) | Inline code |
| text | Rich Text Link | Hyperlink |
| - item / * item / + item | Rich Text List (bullet) | Unordered list |
| 1. item | Rich Text List (ordered) | Ordered list |
| - nested | Rich Text List (indent) | Nested lists (multi-level) |
| 5. item | Rich Text List (offset) | Custom start number |
| - [ ] task / - [x] task | Rich Text List | Task checkboxes (stripped) |
| ``code` | Rich Text Preformatted | Code block (no language specified) | `lang` | Context Block + Rich Text Preformatted | Code block with language context |> quote | Rich Text Quote | Blockquote |--- / * / ___ | Divider Block | Horizontal rule |
/
| \n | Line break (converted before parsing) |:emoji: | Emoji | Emoji shortcode |!alt / ![]()
| Image Block | Alt text as title, Slack file URL supported |
| Divider section | Collapsible section with dividers |Messages are automatically split due to Slack limitations.
- Maximum 50 blocks per message
- Maximum 1 table per message
- Tables are isolated into separate messages
- Header text exceeding 150 characters is automatically split into multiple headers