Common OWL/RDFS Vocabularies for use with Ruby RDF.rb


This gem extends RDF::Vocabulary with #to_ttl, #to_jsonld, and #to_html methods to create special-purpose vocabulary serializations. The HTML version is templated using a Haml template to allow output to be customized.

Also extends RDF::Vocabulary::Format with the gen-vocab command extension to the rdf executable.

Limiting vocabularies used for lookup

As loading vocabularies can dominate processing time, the RDF::Vocabulary.limit_vocabs method can be used to set a specific set of vocabularies over which to reason. For example:

RDF::Vocabulary.limit_vocabs(:rdf, :rdf, :schema)

will limit the vocabularies which are returned from RDF::Vocabulary.each, which is used for reasoning and other operations over vocabularies and terms.



Add to your Gemfile

gem "rdf-vocab"


bundle install


require "rdf/vocab"

This will load all the vocabulary classes in the library.

Also adds the gen-vocab command to the rdf command-line executable to generate specifically generated output in Turtle, JSON-LD, and HTML+RDFa for either built-in or arbitrary vocabularies. Other output serialization formats are also supported as generic RDF Writers and may lack the vocabulary-specific formatting of Turtle, JSON-LD, and HTML+RDFa.

Adding new vocabularies

  • First, add an entry to lib/rdf/vocab.rb, the key names contained within for guidance. For more information, see the documentation on RDF::Vocabulary.

  • Next, create an empty file in lib/rdf/vocab based on the key name for your vocabulary. For example, if you’ve added the vocabulary :foo, create a new empty file at lib/rdf/vocab/foo.rb.

  • Run rake gen_vocabs.



This repository uses Git Flow to mange development and release activity. All submissions must be on a feature branch based on the develop branch to ease staging and integration.

  • Do your best to adhere to the existing coding conventions and idioms.

  • Don’t use hard tabs, and don’t leave trailing whitespace on any line. Before committing, run git diff --check to make sure of this.

  • Do document every method you add using YARD annotations. Read the tutorial or just look at the existing code for examples.

  • Don’t touch the .gemspec or VERSION files. If you need to change them, do so on your private branch only.

  • Do note that in order for us to merge any non-trivial changes (as a rule of thumb, additions larger than about 15 lines of code), we need an explicit public domain dedication on record from you, which you will be asked to agree to on the first commit to a repo within the organization. Note that the agreement applies to all repos in the Ruby RDF organization.


This is free and unencumbered public domain software. For more information, see unlicense.org/ or the accompanying LICENSE file.