---
title: "toggleNode command"
description: "Use the toggleNode command in your Tiptap Editor to toggle one node with another. Learn more in our docs!"
canonical_url: "https://tiptap-docs.lin52025i.qzz.io/editor/api/commands/nodes-and-marks/toggle-node"
---

# toggleNode command

Use the toggleNode command in your Tiptap Editor to toggle one node with another. Learn more in our docs!

`toggleNode` will toggle a node with another node. Both nodes must be text block nodes.

## Parameters

`typeOrName: string | NodeType`

The type of node that should be toggled.

`toggleTypeOrName: string | NodeType`

The type of node that should be used for the toggling.

`attributes?: Record<string, any>`

The attributes that should be applied to the node. **This is optional.**

## Use the toggleNode command

```js
// toggle a paragraph with a heading node
editor.commands.toggleNode('heading', 'paragraph', { level: 1 })

// toggle a paragraph with a code block
editor.commands.toggleNode('codeBlock', 'paragraph')
```
