ToolZoneX
Blog

JSON-LD to Flattened Converter

Paste a JSON-LD document to flatten it, collecting every node — however deeply nested — into a single flat array indexed by @id. Free online developer tool.

Paste JSON-LD Document
Flattened JSON-LD
Flattened output will appear here...

Free JSON-LD to Flattened Converter

Paste a JSON-LD document to flatten it — collecting every node, however deeply nested, into a single flat array indexed by @id. 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. The tool expands the document internally, then pulls every node out into one top-level array, replacing nested object references with lightweight @id pointers. The output is in expanded (full-IRI) form rather than recompacted against your original context.

Example

The sample document above only has one node, so flattening mainly shows its properties rewritten as full IRIs (http://schema.org/name, http://schema.org/url) inside a single-element array. The effect is much more visible on documents with multiple nested objects, where each one gets pulled out to the top level with its own @id.

Common Use Cases

  • Turning a deeply nested JSON-LD document into a flat list of nodes for easier indexing.
  • Preparing data for import into a triple store or graph database that expects node-per-record input.
  • Making every node in a document individually addressable by @id.
  • Simplifying a document's structure before writing custom processing code against it.

FAQs

What does flattening do?

Flattening collects every node in a JSON-LD document — including deeply nested ones — into a single flat array, each with its own @id, and replaces nested object references with @id-only pointers. It removes multiple levels of nesting from the document's structure, which makes it easier to look up any node by its identifier without walking the whole tree.

How is flattening different from expansion?

Expansion resolves shorthand terms into full IRIs but keeps the document's original nested shape. Flattening goes a step further: it also restructures the document itself, pulling every node — nested or not — out into one flat top-level array of node objects. In this tool, flattening runs on the expanded form internally and the result is itself in expanded (IRI) form, not recompacted against your original context.

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.