Tags let you mark and organize cells for different purposes

Tags in Jupyter Notebook are labels you attach to individual cells so you can find them later, hide them from output, or run them selectively. They are not visible in the notebook itself — they live in the cell metadata, a hidden layer that stores information about each cell. You add tags through the cell tags panel, a built-in interface that appears on the right side of your notebook when you enable it.

The most common reason to use tags is to mark cells you want to exclude from a final report or presentation. For example, you might tag all your data-cleaning code with "setup" so you can hide those cells when you share the notebook with someone who only cares about the results. Tags also work with tools like nbconvert, which can strip out tagged cells when you export your notebook to HTML, PDF, or other formats.

Key Takeaways

  • Tags are metadata labels attached to cells that let you organize, hide, or filter cells without changing the notebook itself.
  • You enable the tags panel by clicking the gear icon in the toolbar, then selecting "Tags" from the cell toolbar dropdown.
  • Once the tags panel is visible, you type a tag name into the text field and press Enter to add it to the selected cell.
  • You can remove a tag by clicking the X next to its name in the tags panel, and a single cell can hold multiple tags at once.
  • Tags work with nbconvert to exclude cells from exported documents, and with Jupyter extensions that filter or highlight tagged cells.

Enable the tags panel in your notebook

By default, the tags panel is hidden. To turn it on, look at the toolbar at the top of your notebook — you will see a gear icon on the right side. Click it and a dropdown menu appears with options like "Edit Metadata" and "Tags". Select "Tags" and a small panel will appear on the right edge of your notebook, next to each cell.

If you do not see the gear icon, you may be using an older version of Jupyter or a different interface like JupyterLab. In JupyterLab, right-click on any cell and select "Show Tags" from the context menu. The tags panel will then appear as a sidebar on the right side of the screen.

Add a tag to a single cell

Click on the cell you want to tag — it will be highlighted with a blue border. Look at the tags panel on the right side. You will see a text field that says "Add tag" or shows existing tags if the cell already has any. Type the name of your tag directly into that field. Tag names should be lowercase, with no spaces — use hyphens or underscores if you need to separate words, like "data-cleaning" or "exploratory_analysis".

Press Enter after typing the tag name. The tag will appear as a small label in the tags panel, usually in a colored box. You can now move to another cell and repeat the process. A single cell can have multiple tags — just type each one into the field and press Enter after each one.

Remove or change tags

To remove a tag from a cell, click on the cell to select it, then look at the tags panel. Find the tag you want to delete and click the X button next to it. The tag disappears when ready. There is no undo, but since tags are just labels, you can always add it back by typing it again.

To change a tag name, remove the old tag and add a new one. Jupyter does not have a "rename all instances" feature for tags, so if you used the same tag on many cells and want to change it everywhere, you will need to remove and re-add it on each cell individually. For large notebooks, this is one reason to plan your tag names before you start tagging — consistency saves time later.

Use tags to hide cells when exporting

Once you have tagged your cells, you can use those tags to exclude them from exported documents. The tool for this is nbconvert, which comes with Jupyter. From the command line, you can export your notebook and remove all cells with a specific tag. For example, if you tagged all your setup code with "setup", you could run this command in your terminal:

jupyter nbconvert --to html --TagRemovePreprocessor.remove_cell_tags='["setup"]' your_notebook.ipynb

This command exports your notebook to HTML but removes every cell tagged "setup" from the output. You can list multiple tags by separating them with commas inside the brackets. The original notebook is not changed — only the exported file is affected. This is useful when you want to share results with someone who does not need to see your working code.

View and manage all tags in your notebook

As your notebook grows, you may lose track of which tags you have used and which cells have them. In JupyterLab, you can see all tags at once by opening the Tags panel from the left sidebar — look for an icon that looks like a tag or label. This panel shows every tag in your notebook and how many cells have each one. Clicking a tag in this panel highlights all cells with that tag.

In classic Jupyter Notebook, there is no built-in way to see all tags at once, but you can view the notebook's raw JSON by opening it in a text editor. Look for the "tags" field inside each cell's metadata. This is not practical for regular use, but it can help you troubleshoot if tags are not appearing where you expect them.

Common tag naming patterns

Successful tagging depends on choosing names that make sense to you and anyone else who reads your notebook. A few patterns work well: use "setup" or "imports" for cells that load data or libraries, "exploratory" for cells that test ideas without being part of the final analysis, "results" for cells that produce the main findings, and "notes" or "todo" for cells with comments or work in progress.

Keep tag names short and descriptive. "data-clean" is better than "cleaning-the-data-step-one". If you work on notebooks with other people, agree on a tag naming scheme before you start — having everyone use "setup" instead of some people using "setup" and others using "initialize" prevents confusion later. You can also use tags to mark cells by purpose rather than content: "slow" for cells that take a long time to run, "manual-check" for cells that need human review, or "deprecated" for code you are keeping for reference but no longer use.

Frequently Asked Questions

Can I search for cells by tag?

Classic Jupyter Notebook does not have a built-in search feature for tags. JupyterLab's Tags panel lets you click a tag to highlight all cells with that tag, which is the closest equivalent. If you need more powerful search, you can use a Jupyter extension like nbsearch or write a straightforward Python script that reads your notebook file and finds all cells with a specific tag.

Do tags affect how my code runs?

No. Tags are metadata only — they are stored separately from your code and have no effect on execution. You can run cells in any order, and the tags will not change the output. Tags only matter when you export your notebook or use an extension that reads them.

What happens to tags when I save my notebook?

Tags are saved automatically in your notebook file as part of the cell metadata. When you close and reopen the notebook, all your tags will still be there. If you share the notebook file with someone else, the tags come along with it.

Can I use tags with Jupyter notebooks in Google Colab?

Google Colab does not have a built-in tags panel like classic Jupyter or JupyterLab. You can still add tags manually by editing the notebook's JSON, but there is no user-friendly interface for it. If you need tags in Colab, consider using comments or cell naming conventions instead.

How many tags can I add to one cell?

There is no hard limit. You can add as many tags as you want to a single cell, though in practice more than three or four tags per cell becomes hard to manage. Use tags sparingly — if every cell has five tags, the tags become less useful as an organizational tool.