JSON-LD to Compacted Converter
Paste a JSON-LD document to compact it against its own @context (or an empty context), shortening IRIs into terms and cleaning up structural noise. Free online developer tool.
Paste JSON-LD Document
Compacted JSON-LD
Compacted output will appear here...
Free JSON-LD to Compacted Converter
Paste a JSON-LD document to compact it — rewriting it to use the short terms defined in its context instead of full IRIs, and cleaning up structural noise like single-element arrays. Runs entirely in your browser using the official jsonld.js reference implementation.
How to Use It
Paste any JSON-LD document into the input box, or click "Load Example" to see a sample run. This tool compacts the document against its own @context if it has one; if the document has no @context, it compacts against an empty context, which still tidies up structure without shortening any names.
Example
Given the sample document above, compaction uses the @context mapping name to http://schema.org/name and homepage to http://schema.org/url to keep the document exactly as written — it already is in its most compact form relative to that context. Feed it an already-expanded document instead and you'll see full IRIs collapse back down to name and homepage.
Common Use Cases
- Turning a verbose, expanded JSON-LD document back into a short, readable form for humans.
- Re-compacting a document against a different context to see it expressed with different terms.
- Verifying that a hand-written context actually shortens the IRIs you expect it to.
- Preparing a JSON-LD document for storage or transmission in its most compact representation.
FAQs
Where does the context used for compaction come from?
If your document already has its own @context (the common case — see the example above), this tool compacts against that same context, which is exactly what compaction is meant to do: shorten the document using terms it already defines. If the document has no @context at all, compaction runs against an empty context ({}), which still normalizes structure (for example, collapsing single-value arrays into plain values) but can't shorten any IRIs into short terms, since there are no terms to shorten them to.
What does compaction actually change in a JSON-LD document?
Compaction rewrites a JSON-LD document to use the short terms, prefixes, and aliases defined in a context instead of full IRIs, and simplifies structural noise like single-element arrays and redundant @id wrappers. It's the inverse of expansion — the same data, expressed as compactly as the context allows.
Does this tool support remote @context URLs (like https://schema.org/)?
No — this tool intentionally disables network fetches for @context and document dereferencing, since a static, client-side tool can't reliably rely on a remote server's CORS policy or availability. Use a document with an inline @context object (a JSON object, not a URL string) — the sample document above and virtually every hand-written JSON-LD example works this way. If you paste a document whose @context is a URL, you'll get a clear error instead of an unpredictable network failure.
Is my document uploaded anywhere?
No — all JSON-LD processing happens entirely client-side in your browser using the jsonld.js library. Nothing you paste is sent to a server.
