---
title: "Extract data from PDF form fields using JavaScript library | Nutrient"
canonical_url: "https://www.nutrient.io/guides/web/forms/extract-form-data/"
md_url: "https://www.nutrient.io/guides/web/forms/extract-form-data.md"
last_updated: "2026-05-23T00:08:18.171Z"
description: "You can extract the values of all the form fields present in a PDF using Instance#getFormFieldValues. It returns a simple JavaScript object."
---

# Extract data from PDF form fields using JavaScript

You can extract the values of all the form fields present in a PDF using [`Instance#getFormFieldValues`](https://www.nutrient.io/api/web/NutrientViewer.Instance.html#getFormFieldValues). It returns a simple JavaScript object, where the keys refer to the [`FormField#name`](https://www.nutrient.io/api/web/NutrientViewer.FormFields.FormField.html#name) of the form field and the value is either `null`, `string`, or `Array<string>`, depending upon the type of the [`FormField`](https://www.nutrient.io/api/web/NutrientViewer.FormFields.FormField.html):

```js

const formFieldValues = instance.getFormFieldValues();
console.log(formFieldValues); // { textField: 'Text Value', checkBoxField: ['A', 'B'], buttonField: null }

```

## Extracting form data as Instant JSON

[Instant JSON](https://www.nutrient.io/guides/web/json.md) is optimized for annotations. However, generating Instant JSON from a document will include form field values as well.

Form fields that have been saved can be exported in the Instant JSON format using the [`Instance#exportInstantJSON`](https://www.nutrient.io/api/web/NutrientViewer.Instance.html#exportInstantJSON) API method, and you can look for their values within `formFieldValues`:

```js

const instantJSON = await instance.exportInstantJSON();

const formFieldValues = instantJSON.formFieldValues;
console.log(formFieldValues); // [{"name":"Form Field","type":"pspdfkit/form-field-value","v":1]

```

Note that this method will only yield the changes (diff) in form field values after saving the document.
---

## Related pages

- [JavaScript PDF fillable form library](/guides/web/forms.md)
- [Flatten dynamic PDF forms using JavaScript](/guides/web/forms/flatten.md)
- [Read PDF form fields using JavaScript](/guides/web/forms/read-form-fields.md)
- [Validate PDF forms using JavaScript](/guides/web/forms/javascript-validation.md)
- [Master PDF actions with JavaScript integration](/guides/web/forms/pdf-actions-support.md)

