Skip to main content

slack-as-markdown

pypi python

Read a Slack message as Markdown: its rich text and other blocks, the attachments hung off it, or its mrkdwn text when it has nothing else. The output is meant for a reader such as an LLM, so it keeps what the message shows and leaves out how Slack stores it.

from slack_as_markdown import message_as_markdown

message = {
    "type": "message",
    "text": "Release notes\n*Fixed* the login loop :tada:",
    "blocks": [
        {
            "type": "rich_text",
            "elements": [
                {
                    "type": "rich_text_header",
                    "level": 2,
                    "elements": [{"type": "text", "text": "Release notes"}],
                },
                {
                    "type": "rich_text_list",
                    "style": "bullet",
                    "indent": 0,
                    "elements": [
                        {
                            "type": "rich_text_section",
                            "elements": [
                                {"type": "text", "text": "Fixed", "style": {"bold": True}},
                                {"type": "text", "text": " the login loop "},
                                {"type": "emoji", "name": "tada", "unicode": "1f389"},
                            ],
                        }
                    ],
                },
            ],
        }
    ],
}

print(message_as_markdown(message))
## Release notes
- **Fixed** the login loop 🎉

Why

A message's text is a summary Slack writes beside its blocks, and it loses things the blocks keep: a heading becomes a plain line, a code fence loses its language, and characters a person pasted read the same as formatting they typed. Slack's composer also turns what people type and paste into rich text blocks, so reading the blocks is reading what the message shows.

Install

pip install slack-as-markdown

The package uses the standard library only.

Usage

Pass a message as conversations.history or conversations.replies returns it:

from slack_as_markdown import message_as_markdown

markdown = message_as_markdown(message)

message_as_markdown reads the blocks first, and the text as mrkdwn where the blocks carry nothing. The attachments come after, where Slack draws them.

The parts are available on their own too:

Function Reads
message_as_markdown(message) A whole message
blocks_as_markdown(blocks) A message's blocks
attachments_as_markdown(attachments) A message's attachments
mrkdwn_as_markdown(text) A string in Slack's mrkdwn

Every function takes the value as Slack returns it and returns a string, empty when there is nothing to read.

What is read

  • Rich text: paragraphs, headings at their level, bullet and numbered lists with their nesting and numbering, quotes, code blocks with their language, and rules. Bold, italic, strike and code are written as Markdown; underline, which Markdown has no syntax for, is left as text.
  • Rich text elements of a kind not listed here: read through the fallback Slack attaches to them, or as the words they hold. The same goes for an inline element, such as a color, which is written as its value.
  • Other blocks: header, section, context, markdown, table, image, video, divider, plan, actions and input, and the blocks inside container, card and carousel. Buttons, menus and input fields are named in brackets, such as [buttons: Approve | Deny]. A block of a kind not listed here is read for the text it holds.
  • Attachments: an app's attachment, read as its pretext, author, title, text, fields, image, footer and buttons. A message shared into another is read from the original's blocks, under its author, with a link back to it.
  • Mentions: written in Slack's own form, such as <@U0123456>, <#C0123456> and <!here>, in text with the name after the | left as written. Slack sends IDs only, and an agent replying can write the same form back.
  • Emoji: an emoji in rich text is written as the character, skin tone included; an emoji a workspace added comes with no character and keeps its name, such as :partyparrot:. A shortcode in mrkdwn text, such as :rocket:, is left as written.

Out of scope

  • Files: a message's files are not read. Their names and contents are for the caller to fetch and place.
  • Names: user and channel names are not looked up. Doing so needs API calls, and every function here is a pure function of its input.
  • Exact rendering: the output is Markdown a reader understands, not a guarantee that a Markdown renderer draws it the way Slack does. Characters a person typed as text, such as 2*3*4, are not escaped.

How the shapes are known

Slack documents the structure of blocks. The tests are also checked against messages posted to Slack and read back, kept with their IDs replaced under tests/fixtures/observed.

License

MIT

Metadata

Release files for slack-as-markdown 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slack-as-markdown 0.1.0
File Size Uploaded Provenance Actions
slack_as_markdown-0.1.0.tar.gz 35.4 kB With provenance Details for slack_as_markdown-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for slack-as-markdown 0.1.0
File Interpreter ABI Platform Actions
slack_as_markdown-0.1.0-py3-none-any.whl Python 3 none any Details for slack_as_markdown-0.1.0-py3-none-any.whl

Total release size: 52.0 kB

Release files / slack_as_markdown-0.1.0.tar.gz

Download URL slack_as_markdown-0.1.0.tar.gz
Size 35.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fd272d03916eff13f82838846f9eab72c1119e8cc8ea4c4850bb1f6661246db7
BLAKE2b-256 checksum
How to use checksums
a47b28c10695af58b946babfefa50278966ffb4447889f8e08dc97f213bf69d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / slack_as_markdown-0.1.0-py3-none-any.whl

Download URL slack_as_markdown-0.1.0-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
610890e5d8dab3c5cbf1dc0e8394c81f3ad55e4bb48365ddc6c799559730b595
BLAKE2b-256 checksum
How to use checksums
d5fc3c83351e191d0720e1c63c1588844df3613d44906999d3477660dc36f613
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for slack-as-markdown 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for slack_as_markdown-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page