The DataTransfer.types read-only property returns an array of the drag data formats (as strings) that were set in the dragstart event. The order of the formats is the same order as the data included in the drag operation.

The formats are Unicode strings giving the type or format of the data, generally given by a MIME type. Some values that are not MIME types are special-cased for legacy reasons (for example "text").


An array of the data formats used in the drag operation. Each format is a string. If the drag operation included no data, this list will be empty. If any files are included in the drag operation, then one of the types will be the string Files.


This example shows the use of the types and items properties.

<!DOCTYPE html>
<html lang="en">
  <title>Examples of DataTransfer.{types,items} properties</title>
  <meta content="width=device-width" />
    div {
      margin: 0em;
      padding: 2em;
    #target {
      border: 1px solid black;
    function dragstart_handler(ev) {
      console.log("dragStart: = " +;

      // Add this element's id to the drag payload so the drop handler will
      // know which element to add to its tree
      ev.dataTransfer.effectAllowed = "move";

    function drop_handler(ev) {
      console.log("drop: = " +;

      // Get the id of the target and add the moved element to the target's DOM
      const data = ev.dataTransfer.getData("text");;

      // Print each format type
      for (let i = 0; i < ev.dataTransfer.types.length; i++) {
        console.log(`… types[${i}] = ${ev.dataTransfer.types[i]}`);

      // Print each item's "kind" and "type"
      for (let i = 0; i < ev.dataTransfer.items.length; i++) {
          `… items[${i}].kind = ${ev.dataTransfer.items[i].kind}; type = ${ev.dataTransfer.items[i].type}`

    function dragover_handler(ev) {
      // Set the dropEffect to move
      ev.dataTransfer.dropEffect = "move";
      Examples of <code>DataTransfer</code>.{<code>types</code>,
      <code>items</code>} properties
      <li id="i1" ondragstart="dragstart_handler(event);" draggable="true">
        Drag Item 1 to the Drop Zone
      <li id="i2" ondragstart="dragstart_handler(event);" draggable="true">
        Drag Item 2 to the Drop Zone
      Drop Zone


HTML Standard
# dom-datatransfer-types-dev

Browser compatibility

BCD tables only load in the browser

See also