Code Snippets in Slack and Teams: Share, Edit and Highlight

Pasting code into chat without formatting turns it into soup. Slack answers with text snippets, a file-like object with syntax highlighting; Teams answers with code blocks inside the compose box. One twist: Microsoft's old code snippet card was retired for new creations in 2025. Here is what each help page documents.

Miles Crawford

Miles Crawford

4 min read
Two dark code editor windows with colored bars as abstract code lines, linked by a share arrow with curly braces and angle brackets between them
This image was generated with AI

The quick version

In Slack on desktop, click the plus icon next to the message field, choose Create a text snippet, pick a file type for syntax highlighting, paste your code, optionally share it to a conversation, and click Create Snippet. In Teams, type /code in the compose box (or three backticks, or Ctrl+Shift+Alt+B on Windows and web, Cmd+Shift+Option+B on Mac), pick a language, and write or paste your code. Both need the desktop apps for creation.

Slack: creating a text snippet

Slack's snippets are meant for bits of code, configuration files or log files. The create flow lives behind the plus icon next to the message field: choose Create a text snippet, add a title if you like, choose a file type from the drop-down to get syntax highlighting in that language, then type or paste into the Content field. Checking Share this file lets you pick a conversation and add a message before you click Create Snippet. If you already typed the code into the message field, Cmd+Shift+Enter on Mac or Ctrl+Shift+Enter on Windows and Linux opens a pop-up that converts your text to a snippet. One limit to know: Slack says you cannot currently create or share snippets from the mobile apps.

Slack: finding, editing and sharing snippets

To browse every snippet in your workspace, hover over More, select Files, click All files, then filter File type to Snippets. Only the person who created a snippet can edit it: hover over it, click the pencil icon to open it in your browser, edit and Save Changes. Sharing works at creation or any time after: hover over the snippet, click Share file, search for a channel or person, and click Forward. Recipients can download a shared snippet, view a raw version or leave comments. The feature is available to all members and guests on all plans.

Teams: code blocks in the compose box

Teams gives you four ways to insert a code block: type /code in the compose box, press Ctrl+Shift+Alt+B on Windows and web or Cmd+Shift+Option+B on Mac, type three backticks, or open Show Formatting options and select Code Block. A drop-down sets the language for syntax highlighting, and Teams remembers the last language you used. Long lines can be wrapped via More options inside the code block, then Wrap text under Display option. Code blocks can only be created on desktop, but ones created there render on mobile with line numbers, syntax highlighting and automatic wrapping. Once sent, anyone can copy the code directly from the message, and if highlighting looks wrong, Microsoft's advice is to check the selected language.

Teams: collaborative blocks and the retired snippet card

Before sending, More options inside a code block offers Make this collaborative, which turns the block into a Loop component anyone in the chat can edit; the option only exists before sending. Paste more than 30,000 characters and Teams converts the block to a collaborative one automatically so the whole thing stays readable with highlighting intact. The older code snippet message card, added through Format then Code snippet with its own title and wrap options, can no longer be created after May 30, 2025, per Microsoft, though existing snippets still work and can be edited through More options then Edit on the message.

Which one for what?

Our read: Slack's snippet behaves like a lightweight file, so it suits logs and configs people will download, comment on or forward later. Teams' code block suits quick inline sharing in the flow of a conversation, and the collaborative option is the natural pick when you want others to fix the code, not just read it. If your Teams habit was the old snippet card, retrain on /code; the card is gone for new messages.

What to be careful about

  • Both are desktop-only to create. Slack says snippets cannot be created or shared from its mobile apps; Microsoft says code blocks can only be created on desktop.
  • The Teams snippet card is retired. Microsoft states new code snippets cannot be created after May 30, 2025; use code blocks.
  • Only the creator edits a Slack snippet. Teammates can comment but not change it.
  • Collaborative is a pre-send choice in Teams. The option disappears once the message is sent.
  • Highlighting depends on the language pick. Both products highlight per the selected language; Teams remembers your last choice, which can silently mis-highlight a different language.

Sources

Checked October 23, 2026. Steps, shortcuts and limits follow each product's own help articles. The guidance on when to prefer each is ours.