---
title: "setContent command"
description: "Replace the document with a new one using JSON or HTML with the setContent command. Learn more in our docs!"
---

> This page is for Tiptap 2.x. [See the latest version of this page.](https://tiptap.dev/docs/editor/api/commands/content/set-content.md)

# setContent command

Replace the document with a new one using JSON or HTML with the setContent command. Learn more in our docs!

The `setContent` command replaces the document with a new one. You can pass JSON or HTML, both work fine. It’s basically the same as setting the `content` on initialization.

See also: [insertContent](https://tiptap.dev/docs/v2/editor/api/commands/content/insert-content.md), [clearContent](https://tiptap.dev/docs/v2/editor/api/commands/content/clear-content.md)

## Parameters

`content: string`

Pass a string (JSON or HTML) as [content](https://tiptap.dev/docs/v2/guides/output-json-html.md). The editor will only render what’s allowed according to the [schema](https://tiptap.dev/docs/v2/editor/core-concepts/schema.md).

`emitUpdate?: Boolean (false)`

By default, it doesn’t trigger the update event. Passing `true` doesn’t prevent triggering the update event.

`parseOptions?: Record<string, any>`

Options to configure the parsing can be passed during initialization and/or with setContent. Read more about parseOptions in the [ProseMirror documentation](https://prosemirror.net/docs/ref/#model.ParseOptions).

## Use the setContent command

```js
// Plain text
editor.commands.setContent('Example Text')

// HTML
editor.commands.setContent('<p>Example Text</p>')

// JSON
editor.commands.setContent({
  type: 'doc',
  content: [
    {
      type: 'paragraph',
      content: [
        {
          type: 'text',
          text: 'Example Text',
        },
      ],
    },
  ],
})
```
