Skip to main content


This service allows you to do operations (compact, frame...) on JSON-LD files. It heavily relies on the jsonld.js NPM package. Its particularity is that it keeps in cache the context files, to avoid refetching them at every operation. It also allows to create a local context file.



$ yarn add @semapps/jsonld


const path = require('path');
const { JsonLdService } = require('@semapps/jsonld');

module.exports = {
mixins: [JsonLdService],
settings: {
baseUri: 'http://localhost:3000',
localContextFiles: [
path: 'context.json',
file: path.resolve(__dirname, './config/context.json')
remoteContextFiles: [
uri: '',
file: path.resolve(__dirname, './config/context-as.json')

Service settings

baseUriStringrequiredBase URL of the LDP server
localContextFilesArrayLocal context files to create on the given path and put in cache (see example above)
removeContextFilesArrayRemove context files to put in cache (see example above)


All the methods of the jsonld.js NPM package are available as actions:

  • compact
  • expand
  • flatten
  • frame
  • normalize
  • fromRDF
  • toRDF

See the examples to see how to use them.


Same as toRDF but returns quads formatted according to the RDF.JS data model