---
id: api/utilities/buffer
title: Cypress.Buffer | Cypress Documentation
description: >-
  Cypress automatically includes a Buffer polyfill for the browser and exposes
  it as `Cypress.Buffer`.
section: api
source_path: docs/api/utilities/buffer.mdx
version: 3cf5b86b3403f604bdf7f3e35025c3bc3865e02c
updated_at: '2026-05-07T17:44:31.931Z'
---
# Cypress.Buffer

Cypress automatically includes a [Buffer](https://github.com/feross/buffer) polyfill for the browser and exposes it as `Cypress.Buffer`.

Use `Cypress.Buffer` to manipulate binary data, similar to the [nodejs Buffer class](https://nodejs.org/api/buffer.html). Instances are returned by [`cy.readFile()`](/llm/markdown/api/commands/readfile.md) and [`cy.fixture()`](/llm/markdown/api/commands/fixture.md), and it is used with [`.selectFile()`](/llm/markdown/api/commands/selectfile.md).

## Syntax

```
Cypress.Buffer.method()
```

### Usage

**Correct Usage**

```
Cypress.Buffer.method()
```

**Incorrect Usage**

```
cy.Buffer.method() // Errors, cannot be chained off 'cy'
```

## Examples

### Loading binary data read from disk

```
cy.readFile('images/logo.png', null).then((file) => {  expect(Cypress.Buffer.isBuffer(file)).to.be.true  // Do something with `file` Buffer here})
```

### Using dynamic file contents with `.selectFile()`

```
const files = []for (var i = 1; i <= 10; i++) {  files.push(Cypress.Buffer.from(`Contents of file #${i}`))}// Attach 10 files, of the form "Contents of file #1", "Contents of file #2", etc.cy.get('input[type=file]').selectFile(files)
```

## History

| Version | Changes |
| --- | --- |
| [9.3.0](/llm/markdown/app/references/changelog.md) | Added `Cypress.Buffer`. |

## See also

*   [Bundled Libraries](/llm/markdown/app/references/bundled-libraries.md)
