How to Write Code in Notion (With Keyboard Shortcuts)

This is a simple guide to writing, formatting, and copying code in Notion.

Dec 31, 2025
How to Write Code in Notion (With Keyboard Shortcuts)
Notion is a powerful tool that helps you organize your notes, projects, and ideas all in one place. It’s a flexible workspace that many people use for everything from daily tasks to complex project management. But did you know you can also easily add and display code snippets right within your Notion pages?
This feature is incredibly useful for developers, students, or anyone who needs to share or store code alongside their other documentation. Instead of switching between different apps or losing track of important code, you can keep everything neatly organized within your Notion workspace. It makes collaborating on projects involving code much smoother and keeps your information centralized.
Adding code to Notion is straightforward and doesn't require any special technical skills. With just a few clicks, you can format your code beautifully, making it easy to read and understand.
So now let’s get started.

How to Write Code in Notion in 5 Simple Steps

By following these simple steps, you will be able to easily add and manage your code snippets directly within your Notion pages, keeping your workspace organized and efficient.

Step #1: Open Your Notion Page

First, open the Notion page where you want to add your code. This can be an existing page you're already working on or a brand-new page you create specifically for your code. Navigate to the exact spot on the page where you wish to insert the code block. This ensures your code is placed logically within your document.

Step #2: Add a Code Block (With Keyboard Shortcut)

To add a code block, hover over a new line and click the plus (+) icon, or simply type “/code” and press Enter. You can also add it faster using a keyboard shortcut - on Mac, press Cmd + Option + Shift + 8; on Windows or Linux, use Ctrl + Option + Shift + 8 (or Ctrl + Shift + 8, based on your keyboard settings).
notion image

Step #3: Choose Your Language

Once the code block appears, you will see a small dropdown menu, usually labeled "Plain Text" by default, in the top right corner of the block. Click on this menu to open a list of supported programming languages.
Select the specific language your code is written in, such as Python, JavaScript, HTML, or CSS. Choosing the correct language is important because Notion will then apply proper syntax highlighting, making your code much easier to read and understand.
notion image

Step #4: Type or Paste Your Code

Now that your code block is set up and the language is selected, you can begin typing or pasting your code directly into the block. If you are pasting code from another source, simply copy it from your editor and paste it into the Notion code block.
Notion will automatically format the code according to the language you selected, including indentation and color-coding, which greatly improves readability.
notion image

Step #5: Customize and Manage

After adding your code, you have a few options for customization and management. You can copy the code within the block by clicking the "Copy" button that appears in the top right corner when you hover over it.
You can also toggle "Wrap Code" by clicking the three-dot (⋯) menu if your lines of code are very long, which will make them fit within the block without requiring horizontal scrolling.
If you wish, you can also add a title or caption below the code block using a regular text block to describe what the code does or for easy reference.

Wrapping Up: How to Write Code in Notion

Adding code to your Notion pages is a simple yet powerful way to keep your technical documentation and code snippets organized.
By using Notion's dedicated code blocks, you can ensure your code is displayed clearly with proper syntax highlighting, making it easy to read, share, and manage. This straightforward process helps maintain a clean and efficient workspace, allowing you to focus more on your projects and less on scattered information.

Frequently Asked Questions

  1. How do you write code in Notion?
You write code in Notion by inserting a code block using the /code command and selecting the appropriate language.
  1. Can I run code in Notion?
No, Notion does not execute or run code. It only displays code snippets for documentation and reference.
  1. How to insert HTML code into Notion?
You can paste HTML into a Notion code block or embed it using the /embed block if you want it rendered.
  1. How do I add custom code to Notion?
Custom code can be added by pasting it into a code block or embedding it via third-party tools.
  1. How do I write code in Notion?
You can write code in Notion by inserting a code block using the /code command or a keyboard shortcut.