Skip to content

JSON-LD to Compacted Form — Numio

Compacts a JSON-LD document against the context you supply, using jsonld.compact. Full IRIs become your terms or prefix:suffix names, and single-item arrays collapse to plain values.

Turning verbose expanded JSON-LD from an RDF tool into short, readable keys defined by your own context.

JSON-LD

Context

Compacted

When to use it

  • Turning verbose expanded JSON-LD from an RDF tool into short, readable keys defined by your own context.
  • Checking that a context maps the IRIs you expect before publishing it.

How to use

  1. Paste the document (expanded or using any context) into the JSON-LD editor.
  2. Put the target context in the Context editor as an object with an @context key.
  3. Read the result: the context is placed at the top and properties use its terms.

JSON-LD + context

// JSON-LD editor
{
  "@id": "http://example.org/book/1",
  "@type": "http://schema.org/Book",
  "http://schema.org/name": "Dune",
  "http://schema.org/author": {"@id": "http://example.org/frank-herbert"},
  "http://schema.org/datePublished": {"@value": "1965", "@type": "http://www.w3.org/2001/XMLSchema#gYear"}
}

// Context editor
{"@context": {"schema": "http://schema.org/", "title": "schema:name",
  "author": {"@id": "schema:author", "@type": "@id"}}}

Compacted JSON-LD

{
  "@context": {
    "schema": "http://schema.org/",
    "title": "schema:name",
    "author": {
      "@id": "schema:author",
      "@type": "@id"
    }
  },
  "@id": "http://example.org/book/1",
  "@type": "schema:Book",
  "author": "http://example.org/frank-herbert",
  "schema:datePublished": {
    "@type": "http://www.w3.org/2001/XMLSchema#gYear",
    "@value": "1965"
  },
  "title": "Dune"
}

Details and limitations

Properties without a matching term use a prefix if one is defined (schema:datePublished); otherwise they keep the full IRI.

A term with "@type": "@id" lets references compact to plain strings, as with author above.

Runs in your browser with jsonld.js. Both editors must contain valid JSON; remote context URLs are fetched by your browser. If the download fails, the page shows an error naming the context URL.

FAQ

Why is a typed value still an object?

A value with @type (like the xsd:gYear date) stays {"@type", "@value"} unless the context defines a term with that same @type for the property.

Can the Context editor contain a URL?

Yes, as {"@context": "https://..."}. The browser downloads it, so the server must allow cross-origin requests; inline contexts avoid this.

Does compaction change the data?

No. Compaction only changes how IRIs and values are written; expanding the result gives the same graph.

Specifications and references