Tags let you mark and organize cells in Jupyter Notebook

Tags are metadata labels you attach to individual cells in Jupyter Notebook. They don't change how your code runs — they're invisible to the Python interpreter. Instead, tags help you organize your notebook, hide cells from output, or mark cells for special processing by external tools.

You add tags through the cell toolbar, a small interface that appears above each cell when you enable it. Once tagged, you can use those tags to filter which cells appear in your final notebook, exclude certain cells from being executed, or organize long notebooks into logical sections.

Key Takeaways

  • Enable the cell toolbar by clicking View > Cell Toolbar > Tags in the menu bar.
  • Type tag names directly into the text field that appears above each cell — use lowercase, hyphens instead of spaces, and keep names short.
  • Common tags like hide_input and hide_output work with nbconvert to control what appears in exported documents.
  • Tags are stored in the notebook's JSON metadata and persist when you save, but they don't affect code execution.
  • Use tags consistently across your notebook so filtering and processing tools recognize them reliably.

Enable the cell toolbar to see the tags field

The tags interface is hidden by default. To make it visible, open your Jupyter Notebook and click the View menu at the top. Select Cell Toolbar, then choose Tags from the dropdown that appears.

A small text input field will now appear above every cell in your notebook. This is where you type tag names. If you want to turn off the toolbar later, go back to View > Cell Toolbar and select None.

Type tag names into the field above each cell

Click the text field above any cell and type a tag name. Use lowercase letters, numbers, and hyphens — avoid spaces and special characters. For example, data-cleaning, visualization, or final-results are all valid tag names.

You can add multiple tags to a single cell by separating them with commas. Type setup, import, required to add three tags at once. Press Enter or click elsewhere to save the tags — they're stored immediately in your notebook file.

Use standard tags that work with nbconvert

If you plan to export your notebook to HTML, PDF, or another format using nbconvert, certain tag names have built-in meaning. The tag hide_input hides the code cell but shows the output. The tag hide_output shows the code but hides the result. The tag hide_cell hides both code and output entirely.

These tags don't do anything inside Jupyter itself — they only take effect when you run nbconvert. For example, to export a notebook and hide all input cells, you would run: jupyter nbconvert --to html --TagRemovePreprocessor.remove_cell_tags='["hide_input"]' your_notebook.ipynb

If you're not using nbconvert, you can create any tag names you want. Tags are just labels; they only matter if a tool or script is designed to read them.

Tags are stored in notebook metadata, not in cells

When you save your notebook, tags are stored in the notebook's JSON structure, not in the cell code itself. You can see this by opening your .ipynb file in a text editor — each cell will have a "tags" field in its metadata section.

Because tags live in metadata, they travel with your notebook when you share it. Anyone who opens the file will see the same tags you added. If you remove a tag from the toolbar, it disappears from the metadata immediately.

Filter and search notebooks by tags

Jupyter itself doesn't have a built-in search-by-tags feature in the interface, but you can use external tools. The nbgrep package lets you search for cells with specific tags across multiple notebooks. Install it with pip install nbgrep, then run nbgrep --tag your-tag-name to find all cells with that tag.

You can also write a short Python script to read your notebook file and print all cells with a given tag. This is useful if you want to extract specific sections or run only tagged cells. Many people use tags this way to separate exploratory work from production code in the same notebook.

Common mistakes and how to avoid them

The most common mistake is using spaces or uppercase letters in tag names. Stick to lowercase and hyphens: data-import instead of Data Import. If you use inconsistent names like import, Import, and data_import for the same concept, filtering tools won't recognize them as the same tag.

Another mistake is assuming tags affect code execution. They don't. If you tag a cell skip-this, it will still run when you press Shift+Enter. Tags are purely organizational. If you want to prevent a cell from running, you need to use a different approach, like commenting out the code or using cell magic commands like %%skip (which requires a custom extension).

Frequently Asked Questions

Can I search for tags within Jupyter Notebook?

Jupyter's built-in interface doesn't have a search-by-tags feature. You can see all tags in the toolbar above each cell, but you'll need external tools like nbgrep or a custom script to search across many cells or notebooks. The easiest approach is to use Ctrl+F to search your notebook file for the tag name in the toolbar.

Do tags affect how my code runs?

No. Tags are metadata only — they're completely invisible to Python. Your code runs exactly the same whether a cell is tagged or not. Tags only matter when you export your notebook with nbconvert or use a tool that's designed to read them.

What happens to tags when I share my notebook?

Tags are saved in the notebook file itself, so they travel with it. Anyone who opens your notebook will see the same tags you added. If they edit the tags, their changes are local to their copy unless they share the file back to you.

Can I use tags to organize cells into sections?

Yes, informally. You can tag related cells with names like section-1 or data-prep to keep track of what each cell does. However, Jupyter doesn't have a built-in section feature — tags are just labels. For a more structured approach, consider using markdown cells with headings to visually separate sections.

How do I remove a tag from a cell?

Click the tag field above the cell and delete the text, then press Enter. The tag disappears immediately. If a cell has multiple tags separated by commas, you can delete just one by removing that word and the comma around it.