How to Post Code Blocks in Slack
Use backticks for inline code and triple backticks for multi-line code blocks in Slack messages, and know what Slack does not support.
Direct answer
Wrap inline code in single backticks and multi-line code in triple backticks, exactly like Markdown fences. Slack renders both in a monospaced block, but it does not support language syntax highlighting, so the ```language tag is ignored.
Open Markdown to Slack converterWhen to use this
- You are pasting a command, snippet, or log into a Slack message.
- You want a monospaced block instead of Slack auto-formatting your text.
- You need to share multi-line code that keeps its indentation.
Steps
- For a short snippet in a sentence, wrap it in single backticks.
- For multi-line code, open and close with triple backticks on their own lines.
- Paste the code between the fences; indentation is preserved.
- Drop any language tag after the opening fence — Slack ignores it.
- Send, and confirm the block rendered as monospace.
Example conversion
Run `npm run build`, then: ``` git commit -m "feat: add slack guides" git push ```
Run `npm run build`, then: ``` git commit -m "feat: add slack guides" git push ```
Common mistakes
- Slack has no syntax highlighting; a ```js tag is ignored and the code stays monochrome.
- In the message composer, triple backticks may auto-open a code block before you finish typing — paste the closing fence or use Shift+Enter for newlines.
- Very long lines do not wrap inside a Slack code block; they scroll horizontally.
FAQ
- How do I add a code block in Slack?
- Wrap the code in triple backticks on their own lines for a multi-line block, or single backticks for inline code. Both render as monospace, the same syntax as Markdown.
- Does Slack support syntax highlighting in code blocks?
- No. Slack renders code in a monospaced block but does not colorize it, so a language tag after the opening backticks has no effect.
- Why does my Slack code block open early?
- The message composer detects triple backticks as you type and opens a block. Use Shift+Enter for newlines inside it, or paste the whole fenced block at once.
Related Markdown guides
Related Markdown to Slack guides
Slack Message Formatting Syntax (mrkdwn vs Markdown)
Slack uses mrkdwn, not standard Markdown: one asterisk for bold, underscores for italic, and angle-bracket links. Here is the full reference.
Convert Markdown to Slack mrkdwn
Turn standard Markdown into Slack mrkdwn — bold, italic, strikethrough, links, and headings mapped to Slack's syntax.
Slack Bold and Italic Not Working? Use mrkdwn
If **bold** or __italic__ shows literal symbols in Slack, you are using Markdown instead of mrkdwn. Here is the fix.
Paste Formatted Text Into Slack Without Breaking It
Move text from Markdown, Google Docs, or Notion into Slack cleanly by converting to mrkdwn or clearing carried-over formatting.
How to Make Bullet Points and Lists in Slack
Create bullet points and numbered lists in Slack using the composer's list buttons or literal bullet characters for bot messages.