WebTools

307 Useful Tools & Utilities to make life easier.

How to use Microdata to JSON-LD Converter

Modern Standards

Paste your HTML code snippet that contains Microdata attributes into the input box above.

Click the "Convert to JSON-LD" button to initiate the conversion process.

SEO Advantage

The tool will parse your HTML and extract all structured data items into a valid JSON-LD format.

Copy the generated JSON-LD code and use it in your website's head section for better search engine indexing.

Overview of the Microdata to JSON-LD Converter

The Microdata to JSON-LD Converter is an essential, highly-efficient web tool designed specifically for developers, technical SEO professionals, and webmasters looking to modernize their website's structured data. While inline HTML Microdata (using attributes like itemscope, itemtype, and itemprop) has historically been a popular way to mark up web pages for search engines, Google and other major search engines now strongly recommend using the JSON-LD (JavaScript Object Notation for Linked Data) format. JSON-LD allows you to decouple your structured data from the visual HTML presentation, leading to cleaner code, easier maintenance, and fewer parsing errors.

This tool instantly bridges the gap between older markup practices and modern web standards. By simply pasting your legacy HTML containing microdata into the tool, you can effortlessly extract the underlying structured data entities and convert them into a perfectly formatted JSON-LD script block. This enables you to maintain your rich search results (such as review stars, recipe cards, and product pricing snippets) while adopting a more robust and scalable schema implementation.

Technical Architecture & Workflow

Under the hood, this tool relies on a robust backend architecture utilizing PHP's native DOMDocument and DOMXPath classes. When a user submits an HTML snippet, the tool safely loads the code (suppressing standard libxml HTML parsing warnings to handle imperfect or partial snippets) and initiates an XPath query to identify all root itemscope elements. It specifically targets root items—those that have an itemscope attribute but lack an itemprop attribute, ensuring that nested properties are correctly structured as child objects rather than separate entities.

For each identified element, the tool recursively processes its DOM tree, reading the itemtype to determine the Schema.org class (e.g., http://schema.org/Product becomes Product) and mapping all corresponding itemprop elements to their correct JSON-LD key-value pairs. It dynamically extracts values from optimal sources depending on the HTML tag—for instance, pulling the src attribute from image or video tags, the href from link tags, the datetime attribute from time tags, and the content attribute from meta tags. Finally, the tool merges the standardized @context declaration pointing to schema.org and outputs clean, indented JSON using the json_encode function.

Practical Worked Example

To fully understand how the Microdata to JSON-LD tool works, let's look at a realistic scenario where an e-commerce site needs to migrate a product review snippet.

Input: HTML with Microdata

Here is an example of standard HTML code utilizing legacy Microdata attributes:

<div itemscope itemtype="https://schema.org/Product">
  <h1 itemprop="name">Super Fast SSD Drive</h1>
  <img itemprop="image" src="https://example.com/images/ssd.jpg" alt="SSD Drive" />
  <div itemprop="offers" itemscope itemtype="https://schema.org/Offer">
    <span itemprop="priceCurrency" content="USD">$</span>
    <span itemprop="price" content="129.99">129.99</span>
    <link itemprop="availability" href="https://schema.org/InStock" />In Stock
  </div>
  <p itemprop="description">Upgrade your computer's storage with our top-of-the-line Solid State Drive.</p>
</div>

Output: JSON-LD Format

Upon clicking the conversion button, the tool accurately parses the DOM structure and outputs the following valid JSON-LD code, ready to be placed in the <head> of your webpage:

{
    "@context": "https://schema.org",
    "@type": "Product",
    "name": "Super Fast SSD Drive",
    "image": "https://example.com/images/ssd.jpg",
    "offers": {
        "@type": "Offer",
        "priceCurrency": "USD",
        "price": "129.99",
        "availability": "https://schema.org/InStock"
    },
    "description": "Upgrade your computer's storage with our top-of-the-line Solid State Drive."
}

Frequently Asked Questions (FAQ)

Why should I convert my Microdata to JSON-LD?
While search engines still support Microdata, JSON-LD is the format explicitly recommended by Google. JSON-LD scripts are embedded within a single script tag. This separates your structured data from the messy visual HTML markup, meaning you can update your page's design without accidentally breaking your SEO schema. It is also significantly easier for automated scripts and tag managers to inject JSON-LD.
Can the tool handle nested Microdata (items within items)?
Yes, the tool is built to handle deep recursion. By using XPath to navigate the DOM, it accurately matches nested itemscope attributes to their parent elements. As shown in the practical example, the Offer entity is seamlessly mapped as a child object within the primary Product entity.
Does the tool support multiple schema entities in a single HTML snippet?
Absolutely. If your HTML block contains multiple disconnected root itemscope elements (for instance, a list of multiple distinct products or articles), the tool will detect them and output a JSON array containing all the separate JSON-LD objects, while still sharing a single @context declaration.
How does the tool know which attribute to extract the value from?
The internal parser uses a smart fallback mechanism based on standard HTML specifications. If a tag contains a content attribute, that value is prioritized. Otherwise, it looks at the specific tag name: for images, audio, and iframes, it pulls the src attribute; for anchor and link tags, the href; for time tags, the datetime attribute. If none of these match, it falls back to extracting the inner text content of the element.
Will my data be stored or logged on your servers?
No. The conversion process is completely stateless. The provided HTML code is securely processed within the application memory on the server to generate the JSON-LD output, and the data is immediately discarded. Nothing is permanently stored or saved into a database.

Contact

Missing something?

Feel free to request missing tools or give some feedback using our contact form.

Contact Us