npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

shacl-bridge

v1.5.0

Published

TypeScript library and CLI for parsing SHACL documents and transforming them into JSON Schema

Readme

SHACL Bridge

Build Status npm version npm downloads codecov License: MIT

A CLI tool for bidirectional conversion between SHACL (Shapes Constraint Language) and JSON Schema.

Installation

npm install -g shacl-bridge

Usage

CLI

SHACL to JSON Schema

# Convert SHACL file to JSON Schema (outputs to stdout)
shacl-bridge to-json-schema -i input.ttl

# Save to output file
shacl-bridge to-json-schema -i input.ttl -o output.json

# Read from clipboard
shacl-bridge to-json-schema --from-clipboard

# Parse JSON-LD format
shacl-bridge to-json-schema -i input.jsonld --json-ld

# Output each schema definition to separate files
shacl-bridge to-json-schema -i input.ttl --mode multi -o ./schemas/

# Exclude x-shacl-* extension properties from output
shacl-bridge to-json-schema -i input.ttl --exclude-shacl-extensions

JSON Schema to SHACL

# Convert JSON Schema to SHACL Turtle (outputs to stdout)
shacl-bridge to-shacl -i input.json

# Save to output file
shacl-bridge to-shacl -i input.json -o output.ttl

# Read from clipboard
shacl-bridge to-shacl --from-clipboard

# Output as JSON-LD instead of Turtle
shacl-bridge to-shacl -i input.json --json-ld

# Specify base URI for generated shapes
shacl-bridge to-shacl -i input.json --base-uri http://example.org/shapes/

Command Options

to-json-schema

| Option | Description | | ---------------------------- | --------------------------------------------------- | | -i, --input <file> | SHACL file to convert (Turtle or JSON-LD) | | -o, --output <file> | Output file (single mode) or directory (multi mode) | | --from-clipboard | Read SHACL content from clipboard | | --json-ld | Parse input as JSON-LD format | | -m, --mode <mode> | Output mode: single (default) or multi | | --exclude-shacl-extensions | Exclude x-shacl-* properties from output |

to-shacl

| Option | Description | | --------------------- | --------------------------------------- | | -i, --input <file> | JSON Schema file to convert | | -o, --output <file> | Output file for SHACL | | --from-clipboard | Read JSON Schema content from clipboard | | --json-ld | Output as JSON-LD instead of Turtle | | --base-uri <uri> | Base URI for generated shapes |

Output Modes (to-json-schema)

The --mode (-m) option controls how the JSON Schema output is structured:

  • single (default): Outputs a single JSON Schema file with all definitions in $defs
  • multi: Outputs each schema definition to a separate file in the specified directory. References between schemas are converted to external file references (e.g., Person.json instead of #/$defs/Person)

Features

  • Bidirectional conversion between SHACL and JSON Schema
  • Support for Turtle and JSON-LD formats
  • Comprehensive SHACL constraint support
  • Automatic blank node resolution
  • Multi-file output mode for modular schemas

Programmatic API

Install as a dependency:

npm install shacl-bridge

SHACL to JSON Schema

import { ShaclReader } from 'shacl-bridge';

// Convert from Turtle file
const jsonSchema = await new ShaclReader().fromPath('input.ttl').convert();

// Convert from string content
const jsonSchema = await new ShaclReader().fromContent(turtleString).convert();

// Convert from JSON-LD file
const jsonSchema = await new ShaclReader().fromJsonLdPath('input.jsonld').convert();

// Convert from JSON-LD string content
const jsonSchema = await new ShaclReader().fromJsonLdContent(jsonLdString).convert();

// With options (exclude x-shacl-* extensions)
const jsonSchema = await new ShaclReader()
  .fromPath('input.ttl')
  .withOptions({ excludeShaclExtensions: true })
  .convert();

JSON Schema to SHACL

import { ShaclWriter, DEFAULT_PREFIXES } from 'shacl-bridge';

const jsonSchema = {
  $id: 'http://example.org/PersonShape',
  type: 'object',
  properties: {
    name: { type: 'string', minLength: 1 },
    age: { type: 'integer', minimum: 0 },
  },
  required: ['name'],
};

// Convert to Turtle
const turtle = await new ShaclWriter(jsonSchema)
  .getStoreBuilder()
  .withPrefixes({ ...DEFAULT_PREFIXES, ex: 'http://example.org/' })
  .write();

// Convert to JSON-LD
const jsonLd = await new ShaclWriter(jsonSchema)
  .getStoreBuilder()
  .withPrefixes({ ...DEFAULT_PREFIXES, ex: 'http://example.org/' })
  .writeJsonLd();

Development

npm install          # Install dependencies
npm run build        # Build project
npm test             # Run tests
npm run lint         # Lint code

License

MIT