---
id: api/commands/clear
title: clear | Cypress Documentation
description: Clear the value of an input or textarea in Cypress.
section: api
source_path: docs/api/commands/clear.mdx
version: e6988a974973e9090ce70406c38cb2b9e0eac9fa
updated_at: '2026-05-15T15:50:22.536Z'
---
# clear

Clear the value of an `input` or `textarea`.

It is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the subject after `.clear()`.

An alias for [`.type('{selectall}{del}')`](/llm/markdown/api/commands/type.md)

## Syntax

```
.clear().clear(options)
```

### Usage

**Correct Usage**

```
cy.get('[type="text"]').clear() // Clear text inputcy.get('textarea').type('Hi!')cy.get('textarea').clear() // Clear textareacy.focused().clear() // Clear focused input/textarea
```

**Incorrect Usage**

```
cy.clear() // Errors, cannot be chained off 'cy'cy.get('nav').clear() // Errors, 'get' doesn't yield input or textareacy.clock().clear() // Errors, 'clock' does not yield DOM elements
```

### Arguments

**options _(Object)_**

Pass in an options object to change the default behavior of `.clear()`.

| Option | Default | Description |
| --- | --- | --- |
| `animationDistanceThreshold` | [`animationDistanceThreshold`](/llm/markdown/app/references/configuration.md#Actionability) | The distance in pixels an element must exceed over time to be [considered animating](/llm/markdown/app/core-concepts/interacting-with-elements.md#Animations). |
| `force` | `false` | Forces the action, disables [waiting for actionability](#Assertions) |
| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |
| `scrollBehavior` | [`scrollBehavior`](/llm/markdown/app/references/configuration.md#Actionability) | Viewport position to where an element [should be scrolled](/llm/markdown/app/core-concepts/interacting-with-elements.md#Scrolling) before executing the command |
| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.clear()` to resolve before [timing out](#Timeouts) |
| `waitForAnimations` | [`waitForAnimations`](/llm/markdown/app/references/configuration.md#Actionability) | Whether to wait for elements to [finish animating](/llm/markdown/app/core-concepts/interacting-with-elements.md#Animations) before executing the command. |

### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)

*   `.clear()` yields the same subject it was given.
*   It is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the subject after `.clear()`.

## Examples

### No Args

#### Clear the input and type a new value

```
cy.get('textarea').clear()cy.get('textarea').type('Hello, World')
```

## Notes

### Actionability

#### The element must first reach actionability

`.clear()` is an "action command" that follows all the rules of [Actionability](/llm/markdown/app/core-concepts/interacting-with-elements.md).

### Documentation

`.clear()` is an alias for [`.type({selectall}{del})`](/llm/markdown/api/commands/type.md).

Please read the [`.type()`](/llm/markdown/api/commands/type.md) documentation for more details.

## Rules

### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)

*   `.clear()` requires being chained off a command that yields DOM element(s).
*   `.clear()` requires the element to be an `input` or `textarea`.

### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)

*   `.clear()` will automatically wait for the element to reach an [actionable state](/llm/markdown/app/core-concepts/interacting-with-elements.md)
*   `.clear()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed

### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)

*   `.clear()` can time out waiting for the element to reach an [actionable state](/llm/markdown/app/core-concepts/interacting-with-elements.md).
*   `.clear()` can time out waiting for assertions you've added to pass.

## Command Log

**_Clear the input and type a new value_**

```
cy.get('input[name="name"]').clear()cy.get('input[name="name"]').type('Jane Lane')
```

The commands above will display in the Command Log as:

When clicking on `clear` within the command log, the console outputs the following:

## See also

*   [`.blur()`](/llm/markdown/api/commands/blur.md)
*   [`.focus()`](/llm/markdown/api/commands/focus.md)
*   [`.type()`](/llm/markdown/api/commands/type.md)
