# ontouml-js

> Javascript library to create, edit, and query OntoUML models programmatically.

Latest version **1.0.0** (published 2026-07-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ontouml-js
pnpm add ontouml-js
yarn add ontouml-js
bun add ontouml-js
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2026-07-26 |
| First published | 2019-12-17 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 18 |
| Dependencies | 7 |
| Unpacked size | 1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 16 |
| Maintainers | lucasbassetti, claudenirmf, tprincesales |
| Keywords | ontouml, ufo, ontology, conceptual-modeling, ontology-driven, metamodel, json-schema |

## Links

- npm: https://www.npmjs.com/package/ontouml-js
- Repository: https://github.com/OntoUML/ontouml-js
- Homepage: https://ontouml.github.io/ontouml-js/
- Issues: https://github.com/OntoUML/ontouml-js/issues
- npm.io page: https://npm.io/package/ontouml-js

## Dependencies (7)

- [ajv](https://npm.io/package/ajv.md) ^8.20.0
- [tslib](https://npm.io/package/tslib.md) ^2.8.1
- [lodash](https://npm.io/package/lodash.md) ^4.18.1
- [uniqid](https://npm.io/package/uniqid.md) ^5.4.0
- [ajv-formats](https://npm.io/package/ajv-formats.md) ^3.0.1
- [language-tags](https://npm.io/package/language-tags.md) ^1.0.9
- [ontouml-schema](https://npm.io/package/ontouml-schema.md) ^1.0.2

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.0 (latest) — 2026-07-26
- 0.2.0-alpha.3 (alpha) — 2020-05-17
- 0.5.0 — 2021-05-10
- 0.4.1 — 2021-04-20
- 0.4.0 — 2021-03-01
- 0.3.0 — 2021-02-03
- 0.2.0 — 2020-10-19
- 0.1.10 — 2020-07-03
- 0.2.0-alpha.2 — 2020-05-17
- 0.2.0-alpha.1 — 2020-05-17
- 0.2.0-alpha.0 — 2020-05-17
- 0.1.9 — 2020-05-11
- 0.1.8 — 2020-05-11
- 0.1.7 — 2020-05-11
- 0.1.6 — 2020-05-10
- … 11 more at https://npm.io/package/ontouml-js/versions

## README

# ontouml-js

[![CI](https://img.shields.io/github/actions/workflow/status/OntoUML/ontouml-js/ci.yml?style=flat-square&label=CI)](https://github.com/OntoUML/ontouml-js/actions/workflows/ci.yml)
[![npm](https://img.shields.io/npm/v/ontouml-js?style=flat-square)](https://www.npmjs.com/package/ontouml-js)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square)](LICENSE)

A TypeScript/JavaScript library to **create, edit, query, and serialize
[OntoUML](https://ontouml.org) models** programmatically. Models round-trip
to and from [OntoUML JSON](https://w3id.org/ontouml/schema) — the interchange
format shared with the OntoUML visual tools — with byte-identical
serialization.

**📖 Tutorial & documentation: <https://ontouml.github.io/ontouml-js/>** —
a guided tour with live, editable code samples.

## Installation

```sh
npm install ontouml-js
```

The package ships CommonJS and ES module builds with full TypeScript
declarations; Node.js ≥ 18 is required.

## Usage

Projects and their containers (packages, classes) act as factories of fluent
builders for their contents:

```javascript
import { Project, serializationUtils } from 'ontouml-js';

// Create an OntoUML project
const project = new Project();
project.name.add('My Project');

// Projects serve as factories of builders for their contents
const model = project.packageBuilder().root().name('Model').build();

// Container elements, e.g., packages and classes, are also factories of
// builders for their contents
const person = model.classBuilder().kind().name('Person').build();
const school = model.classBuilder().kind().name('School').build();
const date = model.classBuilder().datatype().name('Date').build();
const enrollment = model.classBuilder().relator().name('Enrollment').build();

const studiesAt = model
  .binaryRelationBuilder()
  .material()
  .name('studies at')
  .source(person)
  .target(school)
  .build();

model
  .binaryRelationBuilder()
  .mediation()
  .source(enrollment)
  .target(person)
  .build();

// Relation ends and attributes are fully configurable
studiesAt.sourceEnd.name.add('student');
studiesAt.sourceEnd.cardinality.setAsOneToMany();
studiesAt.targetEnd.name.add('school');
studiesAt.targetEnd.cardinality.setAsZeroToMany();

enrollment.propertyBuilder().type(date).name('enrollment date').build();

// Containers expose their contents, and query methods span the model
model.classes; // the classes in the package
project.attributes; // every attribute in the project
project.getRelatorTypes(); // every class stereotyped «relator»

// Projects serialize into OntoUML JSON (https://w3id.org/ontouml/schema),
// and serialized projects parse back — byte-identically
const json = JSON.stringify(project);
const copy = serializationUtils.parse(json);
```

The library covers the full OntoUML metamodel: classes and their stereotypes,
relations (binary and n-ary), attributes, generalizations and generalization
sets, notes and anchors, diagrams with views and shapes, multilingual naming,
and the [OntoUML/UFO Catalog](https://w3id.org/ontouml-models) metadata
vocabulary. See the [tutorial](https://ontouml.github.io/ontouml-js/) for the
complete tour.

## Development

```sh
npm install
npm test          # run the Jest suite
npm run lint      # type-check with tsc
npm run build     # bundle CJS + ESM + type declarations
```

The tutorial site lives in [`website/`](website/) and its code samples are
type-checked against the library at build time. See [AGENTS.md](AGENTS.md)
for repository conventions, and the
[publish workflow](.github/workflows/publish.yml) for how releases reach npm.

## About

`ontouml-js` is developed and maintained by the [OntoUML](https://ontouml.org)
community. If you want to know more, feel free to open an issue to provide
feedback on the project or reach our team members for more specific cases:

- [Tiago Prince Sales](https://github.com/tgoprince)
- [Claudenir M. Fonseca](https://github.com/claudenirmf)
- [Lucas Bassetti](https://github.com/LucasBassetti)
- [Victor Viola](https://github.com/victorviola)

## License

[Apache 2.0](LICENSE)

---
_Source: https://npm.io/package/ontouml-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
