# @rmlio/yarrrml-parser

> Parse YARRRML descriptions into RML RDF statements

Latest version **1.12.2** (published 2025-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rmlio/yarrrml-parser
pnpm add @rmlio/yarrrml-parser
yarn add @rmlio/yarrrml-parser
bun add @rmlio/yarrrml-parser
```

Provides the commands `yarrrml-parser`, `yarrrml-generator`.

## Health

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

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.12.2 |
| Published | 2025-10-22 |
| First published | 2018-08-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 1006.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 57 |
| Author | Ben De Meester |
| Maintainers | pheyvaer, bjdmeest, dylanvanassche, ghsnd |
| Keywords | RML, YAML, parser, generator |

## Links

- npm: https://www.npmjs.com/package/@rmlio/yarrrml-parser
- Repository: https://github.com/RMLio/yarrrml-parser
- Homepage: https://github.com/RMLio/yarrrml-parser#readme
- Issues: https://github.com/RMLio/yarrrml-parser/issues
- npm.io page: https://npm.io/package/@rmlio/yarrrml-parser

## Dependencies (11)

- [n3](https://npm.io/package/n3.md) ^1.26.0
- [glob](https://npm.io/package/glob.md) ^11.0.3
- [extend](https://npm.io/package/extend.md) ^3.0.2
- [graphy](https://npm.io/package/graphy.md) ^4.3.7
- [yamljs](https://npm.io/package/yamljs.md) ^0.3.0
- [pkginfo](https://npm.io/package/pkginfo.md) ^0.4.1
- [commander](https://npm.io/package/commander.md) ^14.0.0
- [js-logger](https://npm.io/package/js-logger.md) ^1.6.1
- [prefix-ns](https://npm.io/package/prefix-ns.md) ^1.1.0
- [parse-author](https://npm.io/package/parse-author.md) ^2.0.0
- [rdf-isomorphic](https://npm.io/package/rdf-isomorphic.md) ^2.0.1

## Alternatives

- [monaco-yaml](https://npm.io/package/monaco-yaml.md) — 420.1K weekly downloads
- [@crewx/workflow](https://npm.io/package/@crewx/workflow.md) — 3.1K weekly downloads
- [yaml-cat](https://npm.io/package/yaml-cat.md) — 38 weekly downloads
- [nunjucks-in-yaml](https://npm.io/package/nunjucks-in-yaml.md) — 9 weekly downloads
- [shopify-symlinks](https://npm.io/package/shopify-symlinks.md) — 3 weekly downloads

## Recent versions

- 1.12.2 (latest) — 2025-10-22
- 1.12.1 — 2025-09-22
- 1.12.0 — 2025-08-27
- 1.11.0 — 2025-07-10
- 1.10.1 — 2025-06-26
- 1.10.0 — 2025-03-11
- 1.9.0 — 2025-02-26
- 1.8.0 — 2025-02-11
- 1.7.2 — 2024-09-17
- 1.7.1 — 2024-09-17
- 1.6.2 — 2024-02-16
- 1.6.1 — 2023-09-18
- 1.6.0 — 2023-08-22
- 1.5.4 — 2023-06-23
- 1.5.3 — 2023-06-23
- … 42 more at https://npm.io/package/@rmlio/yarrrml-parser/versions

## README

# YARRRML Parser

This library allows to convert [YARRRML](https://w3id.org/yarrrml) rules to [RML](http://rml.io) or [R2RML](https://www.w3.org/TR/r2rml/) rules.

## Install

- `npm i -g @rmlio/yarrrml-parser`

## Usage

### CLI

There are two CLI functions, `yarrrml-parser` and `yarrrml-generator`.
Using the `--help` flag will show all possible commands.

#### yarrrml-parser

If you want to generate RML rules from a YARRRML document,
you do the following: `yarrrml-parser -i rules.yml`.

The rules will be written to standard output.
If you want to write them to a file, you can add the `-o` option.

By default, the parser generates RML rules.
If you want to generate R2RML rules add `-f R2RML`.

If you want to use `rr:class` instead of Predicate Object Maps, use the `-c` flag.

You can use multiple input files too: `yarrrml-parser -i rules-1.yml -i rules-2.yml`.
They are converted to a single RML document.
Note that the keys in `prefixes`, `sources`, and `mappings` have to be unique across all files.
`base` can only be set once.
You find an example at [`test/multiple-input-files`](test/multiple-input-files).

You can overwrite external references via the `-e`.
An external reference starts with `_`.
For example, `-e name=John` will replace all occurrences of `$(_name)` with `John`.
Repeat `-e` for multiple references.
When you do not provide a value for an external reference,
the reference will not be replaced.
You find an example in [`test/template-escape`](test/template-escape).
If you want to use for example `$(_name)` as both an external reference and a normal reference,
then you add a `\` for the latter resulting in `$(\_name)` for the latter.

If you want the outputted RML to be pretty, please provide the `-p` or `--pretty` parameter.

#### yarrrml-generator

If you want to generate YARRRML rules from an RML document, you do the following: `yarrrml-generator -i rules.rml.ttl`.
The rules will be written to standard output.
If you want to write them to a file, you can add the `-o` option.

### Library

`npm i --save @rmlio/yarrrml-parser`

```javascript
let yarrrml = require('@rmlio/yarrrml-parser/lib/rml-generator');

const yaml = "[yarrrml string]";
const y2r = new yarrrml();
const triples = y2r.convert(yaml);

if ( y2r.getLogger().has('error') ) {
   const logs = y2r.getLogger().getAll();
   ...
}
```

## Development

- Clone this repo.
- Install the dependencies via `npm i`
- Update code, if needed.
- Run the tests via `npm test`
  - If you make a new test, make sure the (RML) Turtle is 'pretty'. If you're not sure it's pretty, run `./test/prettify_ttl.js`.
  - If you don't see all the diffs, change the npm `test` script to add the option `--reporter-option maxDiffSize=81920`.
- Make the [CLI](#cli) (based on the code in the cloned repo)
available system-wide via `npm link` (optional).

## Docker

Run (from [DockerHub](https://hub.docker.com/repository/docker/rmlio/yarrrml-parser)):

```bash
docker run --rm -it -v $(pwd)/resources:/data rmlio/yarrrml-parser:latest -i /data/test.yarrr.yml
```

Build from source:

```bash
docker build -t yarrrml-parser .
```

## License

This code is copyrighted by [Ghent University – imec](http://idlab.ugent.be/) and released under the [MIT license](http://opensource.org/licenses/MIT).

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