{
  "doc": {
    "id": "api/utilities/blob",
    "title": "Cypress.Blob | Cypress Documentation",
    "description": "Cypress automatically includes a Blob library and exposes it as `Cypress.Blob`.",
    "section": "api",
    "source_path": "/llm/markdown/api/utilities/blob.md",
    "version": "3cf5b86b3403f604bdf7f3e35025c3bc3865e02c",
    "updated_at": "2026-05-07T17:44:31.931Z",
    "headings": [
      {
        "id": "api/utilities/blob#cypress-blob",
        "text": "Cypress.Blob",
        "level": 1
      },
      {
        "id": "api/utilities/blob#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/utilities/blob#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/utilities/blob#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/utilities/blob#image-fixture",
        "text": "Image Fixture",
        "level": 3
      },
      {
        "id": "api/utilities/blob#using-an-image-fixture-for-jquery-plugin-upload",
        "text": "Using an image fixture for jQuery plugin upload",
        "level": 4
      },
      {
        "id": "api/utilities/blob#getting-dataurl-string",
        "text": "Getting dataUrl string",
        "level": 3
      },
      {
        "id": "api/utilities/blob#create-an-img-element-and-set-its-src-to-the-dataurl",
        "text": "Create an img element and set its src to the dataUrl",
        "level": 4
      },
      {
        "id": "api/utilities/blob#history",
        "text": "History",
        "level": 2
      },
      {
        "id": "api/utilities/blob#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "content": {
    "type": "root",
    "children": [
      {
        "type": "heading",
        "depth": 1,
        "children": [
          {
            "type": "text",
            "value": "Cypress.Blob"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Cypress automatically includes a "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://github.com/nolanlawson/blob-util",
            "children": [
              {
                "type": "text",
                "value": "Blob"
              }
            ]
          },
          {
            "type": "text",
            "value": " library and exposes it as `Cypress.Blob`."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Use `Cypress.Blob` to convert `base64` strings to Blob objects. Useful for testing uploads."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Syntax"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "Cypress.Blob.method()"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Usage"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Correct Usage"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "Cypress.Blob.method()"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Incorrect Usage"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.Blob.method() // Errors, cannot be chained off 'cy'"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Examples"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Image Fixture"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Using an image fixture for jQuery plugin upload"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// programmatically upload the logocy.fixture('images/logo.png').as('logo')cy.get('input[type=file]').then(function ($input) {  // convert the logo base64 string to a blob  const blob = Cypress.Blob.base64StringToBlob(this.logo, 'image/png')  // pass the blob to the fileupload jQuery plugin  // https://github.com/blueimp/jQuery-File-Upload  // used in your application's code  // which initiates a programmatic upload  $input.fileupload('add', { files: blob })})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Getting dataUrl string"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Create an `img` element and set its `src` to the `dataUrl`"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "return Cypress.Blob.imgSrcToDataURL('/assets/img/logo.png').then((dataUrl) => {  const img = Cypress.$('<img />', { src: dataUrl })  cy.get('.utility-blob').then(($div) => {    // append the image    $div.append(img)  })  cy.get('.utility-blob img').click().should('have.attr', 'src', dataUrl)})"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "History"
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Version"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Changes"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "5.0.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Return type of `arrayBufferToBlob`, `base64StringToBlob`, `binaryStringToBlob`, and `dataURLToBlob` methods changed from `Promise<Blob>` to `Blob`"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "5.0.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Added `arrayBufferToBinaryString`, `binaryStringToArrayBuffer` methods."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "See also"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/bundled-libraries.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "Bundled Libraries"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  "token_estimate": 271
}