Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

FormData.get() — read the first value

FormData.get(name) reads the first value with the specified name: a string or File. If no entry exists, it returns null rather than an empty string.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

formData.get(name)

Call FormData.get on an instance as formData.get(name). It returns the first matching entry’s value without changing the data. The result is a string, a File, or null when no entry exists.

Repeated names are allowed: get(name) reads only the first value; getAll(name) returns all values. An empty string "" is an existing value, not a missing entry. Check value === null instead of relying on if (!value).

This is a Web API, not an ECMAScript language feature. The example does not use the DOM and runs unchanged in browsers that provide FormData.get and in Node.js 24. It demonstrates a repeated name, an empty value, and a missing entry.

Examples

const data = new FormData();
data.append("color", "blue");
data.append("color", "green");
data.append("note", "");

console.log(JSON.stringify({
  first: data.get("color"),
  empty: data.get("note"),
  missing: data.get("unknown")
}));

Result

{"first":"blue","empty":"","missing":null}

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources