Import slackifyMarkdown from slackify-markdown and pass a Markdown string to it. The function returns a string formatted specifically for Slack's message formatting requirements (e.g., converting headers to bold, lists to bullet points, and links to the <url|text> format).
Note: This package is ESM-only. If you are using CommonJS, you must use version v4.x of the package.
import { slackifyMarkdown } from 'slackify-markdown';
const markdown = `
# List of items
* item 1
* item 2
* item 3
[here is an example](https://example.com)
`;
const result = slackifyMarkdown(markdown);
console.log(result);
/*
*List of items*
• item 1
• item 2
• item 3
<https://example.com|here is an example>
*/