# shaclc-parse

> A parser for files written with SHACL compact syntax

Latest version **2.0.0** (published 2026-01-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install shaclc-parse
pnpm add shaclc-parse
yarn add shaclc-parse
bun add shaclc-parse
```

## Health

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

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2026-01-09 |
| First published | 2022-11-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 56.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2 |
| Author | Jesse Wright |
| Maintainers | jeswr |
| Keywords | shacl, shaclc, compact, syntax, parse, rdf, ttl, shape, shex |

## Links

- npm: https://www.npmjs.com/package/shaclc-parse
- Repository: https://github.com/jeswr/shaclcjs
- Homepage: https://github.com/jeswr/shaclcjs#readme
- Issues: https://github.com/jeswr/shaclcjs/issues
- npm.io page: https://npm.io/package/shaclc-parse

## Dependencies (2)

- [n3](https://npm.io/package/n3.md) ^2.0.0
- [@rdfjs/types](https://npm.io/package/@rdfjs/types.md) ^2.0.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2026-01-09
- 1.4.3 — 2025-05-25
- 1.4.2 — 2025-05-15
- 1.4.1 — 2025-05-01
- 1.4.0 — 2023-05-07
- 1.3.1 — 2023-05-07
- 1.3.0 — 2023-01-03
- 1.2.1 — 2023-01-02
- 1.2.0 — 2023-01-01
- 1.1.2 — 2023-01-01
- 1.1.1 — 2022-12-31
- 1.1.0 — 2022-12-30
- 1.0.1 — 2022-12-12
- 1.0.0 — 2022-11-21

## README

# shaclc-parse
A parser for files written with [SHACL compact syntax](https://w3c.github.io/shacl/shacl-compact-syntax/)

## Usage
```ts
import { parse } from 'shaclc-parse'

const quads = parse(`
PREFIX ex: <http://example.org/test#>

shape ex:TestShape -> ex:TestClass1 ex:TestClass2 {
	targetNode=ex:TestNode targetSubjectsOf=ex:subjectProperty targetObjectsOf=ex:objectProperty .
}
`, { baseIRI: "http://example.org/basic-shape-with-targets" })
```

## Extended SHACL Compact Syntax

The [SHACL Compact Syntax specification](https://w3c.github.io/shacl/shacl-compact-syntax/) is not expressive enough to
make any RDF 1.0 statement. This package includes an opt-in extended syntax that allows users to make any RDF 1.0 statement. Parsing of this extended syntax can be enabled via an option in the `parse` function

```ts
const quads = parse(/*shaclc extended string*/, { extendedSyntax: true })
```

### Making additional statements about the `NodeShape`

Additional statements can be made about NodeShapes by using a turtle-like syntax before the body of the shape. For instance we can add the following statements to the above `ex:TestShape`.

```ttl
ex:TestShape ex:myCustomAnnotation ex:myCustomValue ;
	ex:myCustomBlankNodeAnnotation [
		ex:myCustomList ( 1 ex:myCustomValue )
	] .
```

by doing the following:

```shaclc
shape ex:TestShape -> ex:TestClass1 ex:TestClass2 ;
	ex:myCustomAnnotation ex:myCustomValue ;
	ex:myCustomBlankNodeAnnotation [
		ex:myCustomList ( 1 ex:myCustomValue )
	] {
		targetNode=ex:TestNode targetSubjectsOf=ex:subjectProperty targetObjectsOf=ex:objectProperty .
	}
```

### Making additional statements about the `sh:property`

additional statements can be made about each blank node property as follows:

```shaclc
shape ex:TestShape -> ex:TestClass1 ex:TestClass2 {
	ex:myPath [0..1] %
		ex:myCustomPropertyAnnotation ex:myCustomPropertyValue ;
		ex:myCustomPropertyAnnotation2 ex:myCustomPropertyValue2 ;
	% .
}
```

### Making arbitrary statements

Finally we permit the use of turtle syntax at the end of the file to make any additional statements


```shaclc
shape ex:TestShape -> ex:TestClass1 ex:TestClass2 {
	targetNode=ex:TestNode targetSubjectsOf=ex:subjectProperty targetObjectsOf=ex:objectProperty .
}

ex:bob a ex:Person .
```

## License
©2022–present
[Jesse Wright](https://github.com/jeswr),
[MIT License](https://github.com/jeswr/shaclcjs/blob/main/LICENSE).

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