JSON-LD Structured Data Extractor

Extract valid application/ld+json script documents from HTML as normalized JSON strings, without resolving remote contexts.

Description

JSON-LD can embed linked-data documents in application/ld+json script elements.

JSON-LD can embed linked-data documents in application/ld+json script elements. Finding those documents is separate from expanding contexts or validating their vocabulary.1, 2

Extract valid application/ld+json script documents from HTML as normalized JSON strings, without resolving remote contexts.

When to use JSON-LD Structured Data Extractor

Use this tool to extract valid application/ld+json script documents from HTML as normalized JSON strings, without resolving remote contexts.

Choose the URL, decoded source text, header value or explicit byte list requested by this tool. Paste the complete relevant input and follow its parsing and encoding conventions.

How to use JSON-LD Structured Data Extractor and understand its results

  1. Choose the URL, decoded source text, header value or explicit byte list requested by this tool. Paste the complete relevant input and follow its parsing and encoding conventions.
  2. Enter html using the field table and calculation rules, then run the tool.
  3. Read documents. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
Input fieldMeaningValue type; see rules belowRequirement
htmlHTML source containing JSON-LD script elements.string; maximum length: 1000000Required

Paste HTML source. The scanner collects script text when its trimmed case-insensitive type is application/ld+json. Each document must parse as a JSON object or array. Return normalized JSON strings in source order; malformed JSON, scalar documents or an unclosed collected script are errors. No matching scripts returns an empty list.

documents=JSON.stringify(JSON.parse(scriptText)) for matching closed scripts

Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.

Output fieldMeaningValue type
documentsNormalized JSON-LD document strings.list of string; maximum length: 1000000; minimum entries: 0; maximum entries: 100000
json
{
  "input": {
    "html": "<script type=\"application/ld+json\">{ \"@type\": \"Article\", \"name\": \"Example\" }</script>"
  },
  "output": {
    "documents": [
      "{\"@type\":\"Article\",\"name\":\"Example\"}"
    ]
  }
}

Limitations and assumptions

Remote contexts are not fetched and JSON-LD semantics are not validated. Script text is not HTML-entity decoded, and source scanning does not execute JavaScript or implement all browser recovery rules.

Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.

Alternative or Complementary methods

Use Meta Tag Parser: Extract named meta entries from HTML source in document order, preserving repeated keys. For a complementary task, use Import Map Parser: Parse imports and scopes from import-map JSON into portable entries, preserving null addresses and leaving URL resolution to the caller.

Further background: JSON-LD 1.1: embedding documents in HTML.

References

  1. JSON-LD Structured Data Extractor — tool.io

  2. JSON-LD 1.1: embedding documents in HTML — W3C

Similar or alternative tools

  • Meta Tag Parser

    Extract named meta entries from HTML source in document order, preserving repeated keys.

  • Import Map Parser

    Parse imports and scopes from import-map JSON into portable entries, preserving null addresses and leaving URL resolution to the caller.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies