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
- Open the page where the snippet belongs.
- Click an empty line below the title.
- Type a slash followed by code.
- Choose Code from the filtered menu.
- Type or paste your snippet into the block.
Interactive 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
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.
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.
Step 3
Choose Code
Pick Code from the filtered results. Notion turns the empty line into a code block.
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.
Related guides
Continue with more step-by-step guides for getting work done.
How to add blocks in NotionLearn how to add blocks in Notion using the slash command menu to insert text, headings, images, databases, and 50+ block types.
How to create a new page in NotionLearn how to create a new page in Notion from the sidebar, from a template, or as a sub-page nested inside an existing page.
How to add a cover image to a page in NotionLearn how to add a cover image to a Notion page: click Add cover, open the Page cover panel, then pick a Gallery image or upload your own picture.
How to add a comment in NotionAdd a comment to a Notion page in three steps: click Add comment under the title, type your note, and send it so teammates can read and reply.
How to add a database property in NotionAdd a property to a Notion database in four clicks: choose Add property, name it, pick a type like Date, and edit it later from the column header.
How to add a Mermaid diagram in NotionLearn how to add a Mermaid diagram in Notion with a code block: pick the Mermaid option, write your diagram text, and expand it fullscreen.
Create interactive demos like this one — free, no coding required.
Start for free →