# @bpmn-io/extract-process-variables

> A util for bpmn-js to extract Camunda BPM process variables from a BPMN 2.0 diagram.

Latest version **2.2.1** (published 2026-02-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bpmn-io/extract-process-variables
pnpm add @bpmn-io/extract-process-variables
yarn add @bpmn-io/extract-process-variables
bun add @bpmn-io/extract-process-variables
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 2.2.1 |
| Published | 2026-02-27 |
| First published | 2020-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 43.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Niklas Kiefer |
| Maintainers | bpmn-io-admin, nikku, barmac, philippfromme, maxtru, skaiir-camunda, vsgoulart, barinali, jarekdanielak, alekseymanetov, simon-steinruecken-camunda |

## Links

- npm: https://www.npmjs.com/package/@bpmn-io/extract-process-variables
- Repository: https://github.com/bpmn-io/extract-process-variables
- Homepage: https://github.com/bpmn-io/extract-process-variables#readme
- Issues: https://github.com/bpmn-io/extract-process-variables/issues
- npm.io page: https://npm.io/package/@bpmn-io/extract-process-variables

## Dependencies (1)

- [min-dash](https://npm.io/package/min-dash.md) ^5.0.0

## Recent versions

- 2.2.1 (latest) — 2026-02-27
- 2.2.0-rc.3 (preview) — 2026-02-22
- 2.2.0 — 2026-02-25
- 2.1.1 — 2026-02-23
- 2.2.0-rc.2 — 2026-02-21
- 2.2.0-rc.1 — 2026-02-20
- 2.2.0-rc.0 — 2026-02-20
- 2.1.0 — 2026-02-17
- 2.0.0 — 2026-02-04
- 1.0.1 — 2025-01-02
- 1.0.0 — 2024-09-23
- 0.9.0 — 2024-08-28
- 0.8.0 — 2023-02-02
- 0.7.0 — 2023-01-03
- 0.6.0 — 2022-10-02
- … 11 more at https://npm.io/package/@bpmn-io/extract-process-variables/versions

## README

# extract-process-variables

[![CI](https://github.com/bpmn-io/extract-process-variables/actions/workflows/CI.yml/badge.svg)](https://github.com/bpmn-io/extract-process-variables/actions/workflows/CI.yml)

An util for [bpmn-js](https://github.com/bpmn-io/bpmn-js) to extract Camunda BPM [process variables](https://docs.camunda.org/manual/latest/user-guide/process-engine/variables/) from a BPMN 2.0 diagram.

## Installation

```sh
$ npm i --save @bpmn-io/extract-process-variables
```

## Usage

### Camunda Platform 7
Given [this example diagram](./test/fixtures/sub-process-own-scope.bpmn)

```js
import {
  getProcessVariables,
  getVariablesForScope,
} from '@bpmn-io/extract-process-variables';

// For Camunda Platform 8 diagrams, use the /zeebe submodule
// import {
//   getProcessVariables,
//   getVariablesForScope,
// } from '@bpmn-io/extract-process-variables/zeebe';

const canvas = modeler.get('canvas');

const rootElement = canvas.getRootElement();

const allVariables = getProcessVariables(rootElement.businessObject);
/*
  [
    {
      "name": "variable1",
      "origin": [ "Task_1" ],
      "scope": "Process_1"
    },
    {
      "name": "variable2",
      "origin": [ "Task_1" ],
      "scope": "Process_1"
    },
    {
      "name": "variable3",
      "origin": [ "Task_2" ],
      "scope": "SubProcess_1"
    }
  ]
*/

const scopeVariables = getVariablesForScope('Process_1', rootElement.businessObject);
/*
  [
    {
      "name": "variable1",
      "origin": [ "Task_1" ],
      "scope": "Process_1"
    },
    {
      "name": "variable2",
      "origin": [ "Task_1" ],
      "scope": "Process_1"
    }
  ]
*/
```

Note that `origin` and `scope` retrieves the full moddle element. The example outputs are reduced due to better readibility.

Note that [camunda-bpmn-moddle](https://github.com/camunda/camunda-bpmn-moddle) or [zeebe-bpmn-moddle](https://github.com/camunda-cloud/zeebe-bpmn-moddle) descriptors have to be installed.

## Properties support

### Camunda Platform 7
We are currently [extracting process variables](https://github.com/bpmn-io/extract-process-variables/tree/main/src/camunda-platform/extractors) from the following diagram properties
* `camunda:formField`
* `camunda:outputParameter`
* `camunda:out`
* `camunda:resultVariable`
* `camunda:errorCodeVariable`
* `camunda:errorMessageVariable`
* `camunda:escalationCodeVariable`

### Camunda Platform 8
We are currently [extracting process variables](https://github.com/bpmn-io/extract-process-variables/tree/main/src/zeebe/extractors) from the following diagram properties
* `zeebe:input`
* `zeebe:output`
* `zeebe:loopCharacteristics > inputElement`
* `zeebe:loopCharacteristics > outputCollection`
* `zeebe:calledDecision > resultVariable`
* `zeebe:script > resultVariable`

## See also

* [camunda-bpmn-moddle](https://github.com/camunda/camunda-bpmn-moddle)
* [Camunda BPM Process Variables Documentation](https://docs.camunda.org/manual/latest/user-guide/process-engine/variables/)
* [zeebe-bpmn-moddle](https://github.com/camunda-cloud/zeebe-bpmn-moddle)
* [Camunda Platform 8 Variables Documentation](https://docs.camunda.io/docs/components/concepts/variables)

## License

MIT

---
_Source: https://npm.io/package/@bpmn-io/extract-process-variables · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
