How to add a code block in Notion

Learn how to add a code block in Notion: type a slash command on an empty line, pick Code from the menu, and enter your snippet in four quick steps.

Quick answer

To add a code block in Notion, click an empty line on a page, type a slash followed by code, then choose Code from the menu that appears. Notion converts the line into a code block, and you can type or paste your snippet straight into it.

Steps at a glance

  1. Open the page where the snippet belongs.
  2. Click an empty line below the title.
  3. Type a slash followed by code.
  4. Choose Code from the filtered menu.
  5. Type or paste your snippet into the block.

Interactive demo

Loading demo…

Summary

A code block in Notion gives snippets, commands, and config a distinct container, separate from your body text. It keeps formatting intact and makes technical notes easy to scan and copy.

Step-by-step guide

  1. Step 1

    Click an empty line

    Open the page where you want the snippet. Click an empty line below the page title so the cursor sits in a blank block.

  2. Step 2

    Type /code

    Type a slash followed by code. Notion opens a menu that filters as you type, so only code-related options remain.

  3. Step 3

    Choose Code

    Pick Code from the filtered results. Notion turns the empty line into a code block.

  4. Step 4

    Type your code

    Click inside the code block and type or paste your snippet, for example a short install command.

Why this matters

You are writing an API quickstart or a setup note and need teammates to copy a command without it blending into your prose. A code block keeps the snippet separate, readable, and easy to find when someone returns to the page later.

Frequently asked questions

  • Can I use a code block on the free plan?

    The capture was made on a free workspace, and the Code option appeared in the menu without any upgrade prompt.

  • Can I turn an existing line into a code block?

    The menu also shows a Turn into version of Code, which converts the line you are on into a code block.

Create interactive demos like this one — free, no coding required.

Start for free →