How to Add Tags to Cells in Jupyter Notebook
Jupyter Notebook cells aren't just containers for code or markdown — they can carry metadata, and one of the most practical forms of that metadata is cell tags. Tags let you label individual cells with custom identifiers, which tools like nbconvert, papermill, and testing frameworks can then act on in meaningful ways.
If you've ever needed to skip a cell during export, inject parameters into a notebook programmatically, or hide certain output from a rendered report, tags are the mechanism that makes all of that possible.
What Are Cell Tags in Jupyter Notebook?
A cell tag is a short string of text stored in the cell's metadata — not in the code itself. Tags live in the notebook's underlying .ipynb JSON file under the metadata.tags key for each cell. They're invisible during normal execution and don't affect how code runs, but they act as flags that external tools can read.
Common uses include:
parameters— marks a cell as the injection point forpapermill, allowing notebooks to accept external inputs at runtimeremove-inputorremove-output— signals tonbconvertor Jupyter Book to hide specific parts of a cell when building HTML or PDF outputsskip— used by some testing frameworks to exclude a cell from automated runs- Custom tags — anything you define for your own pipeline logic
Tags are completely freeform strings. You define them, and the tools that consume the notebook decide what to do with them.
How to Add Tags Using the Jupyter Notebook Interface
Classic Jupyter Notebook (.ipynb interface)
In the classic interface, cell tags are tucked inside the Cell Toolbar.
- Open your notebook.
- Go to View in the top menu, then select Cell Toolbar → Tags.
- A tag input bar will appear at the top of every cell.
- Click inside the tag field for the cell you want to tag, type your tag name, and press Enter or Add tag.
The tag will appear as a small badge. You can add multiple tags to the same cell and remove them by clicking the × next to each tag.
JupyterLab
JupyterLab handles tags through the Property Inspector panel, not a toolbar.
- Click on the cell you want to tag to select it.
- Open the Property Inspector by clicking the settings icon (⚙️) in the right sidebar, or go to View → Show Right Sidebar.
- Expand the Common Tools or Cell Metadata section.
- You'll see a Tags field. Type your tag and press Enter to add it.
In newer versions of JupyterLab (3.x and later), the right panel integrates this more cleanly, but the location of the tag field can shift slightly depending on your installed extensions and version.
How to Add Tags Directly in the Notebook Metadata
If you prefer working closer to the source — or you're automating notebook configuration — tags can be added directly to the .ipynb file, which is plain JSON.
Each cell object in the cells array contains a metadata field. To tag a cell, add a tags key with a list of strings:
"metadata": { "tags": ["parameters"] } This is exactly what tools like papermill look for when scanning a notebook before execution. If the tags key is missing, the metadata block still needs to exist — it just needs to be an empty object {}.
Editing raw JSON is practical when you're building automated pipelines or templating notebooks programmatically, but it carries the risk of breaking the file structure if formatting goes wrong. Always keep a backup or use version control.
Variables That Affect How Tags Behave 🔖
Not all tags do the same thing in every environment. Several factors determine what actually happens when a tag is applied:
| Factor | Effect on Tag Behavior |
|---|---|
| Tool being used | nbconvert, papermill, pytest-notebook, and Jupyter Book each recognize different tag names |
| Jupyter version | The UI location for adding tags differs between classic Notebook and JupyterLab |
| Tag naming conventions | Some tools are case-sensitive or require exact strings (remove-input vs remove_input) |
| Execution environment | Tags have no runtime effect during normal jupyter notebook execution — they only matter to external processors |
| Custom pipeline logic | If you've built your own tooling around nbformat, you define what your tags mean |
This means the same tag string can be inert in one context and critical in another. A cell tagged remove-output does nothing when you run the notebook interactively — it only takes effect when nbconvert processes the file with the right configuration flags enabled.
Tags Across Different User Profiles
Data scientists using papermill rely almost entirely on the parameters tag. One cell per notebook gets this tag, and it defines the default values that papermill will override when executing notebooks as part of a pipeline.
Documentation builders using Jupyter Book frequently use tags like remove-cell, remove-input, and hide-output to control what readers see in published content without deleting the underlying code.
Testing pipelines may use custom tags to mark cells that should be skipped during CI runs — particularly cells that require credentials, large data downloads, or GPU access.
Developers templating notebooks at scale often skip the UI entirely and manipulate tags programmatically using the nbformat Python library, which gives direct access to each cell's metadata dictionary.
What Tags Don't Do
Worth stating plainly: tags are passive labels, not executable logic. They don't change what a cell does when run interactively. They don't reorder cells, control imports, or create dependencies between cells. Their meaning is entirely determined by whatever external tool reads the notebook next.
If you apply a tag and nothing seems to happen, the most likely explanation is that the tool you're using either doesn't recognize that specific tag name or needs to be configured to act on it. The tag itself is stored correctly — the consumer of that tag just needs to be set up to respond.
How far tags take you depends heavily on which tools are already part of your workflow and what those tools are configured to look for.