---
id: api/commands/getalllocalstorage
title: getAllLocalStorage | Cypress Documentation
description: >-
  Get localStorage data for all origins with which the test has interacted in
  Cypress.
section: api
source_path: docs/api/commands/getalllocalstorage.mdx
version: ce02913654e2655ee63448bdc92bb92c7b46a619
updated_at: '2026-04-22T19:37:51.587Z'
---
# getAllLocalStorage

Get
[`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage)
data for all origins with which the test has interacted.

## Syntax

```javascript
cy.getAllLocalStorage()
cy.getAllLocalStorage(options)
```

### Usage

 **Correct Usage**

```javascript
cy.getAllLocalStorage()
```

### Arguments

 **options *(Object)***

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

| Option | Default | Description                                                                                         |
| ------ | ------- | --------------------------------------------------------------------------------------------------- |
| `log`  | `true`  | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |

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

`cy.getAllLocalStorage()` yields an object where the keys are origins and the
values are key-value pairs of `localStorage` data.

For example, if `key1` is set to `value1` on `https://example.cypress.io` and
`key2` is set to `value2` on `https://www.cypress-dx.com`,
`cy.getAllLocalStorage()` will yield:

```js
{
  'https://example.cypress.io': {
    key1: 'value1',
  },
  'https://www.cypress-dx.com': {
    key2: 'value2',
  },
}
```

## Examples

### Get all localStorage

```javascript
cy.visit('https://example.cypress.io', {
  onBeforeLoad(win) {
    win.localStorage.setItem('key', 'value')
  },
})

cy.getAllLocalStorage().then((result) => {
  expect(result).to.deep.equal({
    'https://example.cypress.io': {
      key: 'value',
    },
  })
})
```

## Rules

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

- `cy.getAllLocalStorage()` requires being chained off of `cy`.

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

- `cy.getAllLocalStorage()` will only run assertions you have chained once, and
  will not [retry](/llm/markdown/app/core-concepts/retry-ability.md).

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

- `cy.getAllLocalStorage()` cannot time out.

## See also

- [`cy.clearAllLocalStorage()`](/llm/markdown/api/commands/clearalllocalstorage.md)
- [`cy.clearAllSessionStorage()`](/llm/markdown/api/commands/clearallsessionstorage.md)
- [`cy.clearCookies()`](/llm/markdown/api/commands/clearcookies.md)
- [`cy.clearLocalStorage()`](/llm/markdown/api/commands/clearlocalstorage.md)
- [`cy.getAllSessionStorage()`](/llm/markdown/api/commands/getallsessionstorage.md)
