Microdata vs RDFa vs JSON-LD

Last updated:

Three formats exist for embedding structured data in web pages: JSON-LD, Microdata, and RDFa. All three can express the same Schema.org vocabulary. They differ in how and where you write the markup. This page explains each format, compares them side by side, and helps you choose the right one.

JSON-LD

JSON-LD (JavaScript Object Notation for Linked Data) places structured data in a <script> tag, separate from your HTML content.

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "LocalBusiness",
  "name": "Lakeside Bakery",
  "telephone": "+1-555-867-5309",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "742 Evergreen Terrace",
    "addressLocality": "Springfield",
    "addressRegion": "IL",
    "postalCode": "62704"
  }
}
</script>

The structured data exists as a standalone block. It does not interact with the visible HTML elements on the page.

Microdata

Microdata embeds structured data directly in your HTML using three attributes: itemscope, itemtype, and itemprop.

<div itemscope itemtype="https://schema.org/LocalBusiness">
  <h1 itemprop="name">Lakeside Bakery</h1>
  <p>Phone: <span itemprop="telephone">+1-555-867-5309</span></p>
  <div itemprop="address" itemscope itemtype="https://schema.org/PostalAddress">
    <p itemprop="streetAddress">742 Evergreen Terrace</p>
    <p>
      <span itemprop="addressLocality">Springfield</span>,
      <span itemprop="addressRegion">IL</span>
      <span itemprop="postalCode">62704</span>
    </p>
  </div>
</div>

Each piece of structured data is attached to the HTML element that displays it. The itemscope attribute creates a new item. The itemtype attribute sets its Schema.org type. The itemprop attribute assigns a property.

RDFa

RDFa (Resource Description Framework in Attributes) also embeds structured data in HTML, but uses a different set of attributes: vocab, typeof, and property.

<div vocab="https://schema.org/" typeof="LocalBusiness">
  <h1 property="name">Lakeside Bakery</h1>
  <p>Phone: <span property="telephone">+1-555-867-5309</span></p>
  <div property="address" typeof="PostalAddress">
    <p property="streetAddress">742 Evergreen Terrace</p>
    <p>
      <span property="addressLocality">Springfield</span>,
      <span property="addressRegion">IL</span>
      <span property="postalCode">62704</span>
    </p>
  </div>
</div>

RDFa is similar to Microdata in practice. The main differences are the attribute names and RDFa’s support for multiple vocabularies via prefixes.

Side-by-Side Comparison

Here is the same data — a book — expressed in all three formats.

JSON-LD

{
  "@context": "https://schema.org",
  "@type": "Book",
  "name": "The Design of Everyday Things",
  "author": {
    "@type": "Person",
    "name": "Don Norman"
  },
  "isbn": "978-0465050659",
  "publisher": {
    "@type": "Organization",
    "name": "Basic Books"
  }
}

Microdata

<div itemscope itemtype="https://schema.org/Book">
  <h1 itemprop="name">The Design of Everyday Things</h1>
  <p>By <span itemprop="author" itemscope itemtype="https://schema.org/Person">
    <span itemprop="name">Don Norman</span>
  </span></p>
  <p>ISBN: <span itemprop="isbn">978-0465050659</span></p>
  <p>Publisher: <span itemprop="publisher" itemscope itemtype="https://schema.org/Organization">
    <span itemprop="name">Basic Books</span>
  </span></p>
</div>

RDFa

<div vocab="https://schema.org/" typeof="Book">
  <h1 property="name">The Design of Everyday Things</h1>
  <p>By <span property="author" typeof="Person">
    <span property="name">Don Norman</span>
  </span></p>
  <p>ISBN: <span property="isbn">978-0465050659</span></p>
  <p>Publisher: <span property="publisher" typeof="Organization">
    <span property="name">Basic Books</span>
  </span></p>
</div>

Comparison Table

CriteriaJSON-LDMicrodataRDFa
Placement<script> tag (separate from HTML)Inline HTML attributesInline HTML attributes
HTML modification requiredNoYesYes
ReadabilityHigh (standard JSON)Moderate (interleaved with HTML)Moderate (interleaved with HTML)
Google recommendationYes (preferred)SupportedSupported
Dynamic generationEasy (serialize from any backend)Requires HTML template changesRequires HTML template changes
Visible content couplingNone (can describe content not on page)Tied to visible elementsTied to visible elements
Multiple vocabulariesPossible via @contextNot supportedSupported via prefixes
CMS supportWidely supported (plugins, APIs)LimitedModerate (Drupal)

Pros and Cons

JSON-LD

Pros:

  • Completely decoupled from HTML. You can add or change structured data without modifying templates.
  • Easy to generate server-side from APIs, databases, or CMS data.
  • Easier to read, debug, and maintain.
  • Can describe entities that are not visible on the page (e.g., an organization entity on every page).
  • Recommended by Google.

Cons:

  • Data can drift out of sync with visible content if not managed carefully.
  • Requires a separate script block (minor additional payload).

Microdata

Pros:

  • Data is inherently tied to visible content, reducing the risk of mismatch.
  • No separate script block needed.
  • Historically well-supported by Google.

Cons:

  • Requires modifying HTML templates, which can be difficult in some CMS setups.
  • Makes HTML harder to read with all the extra attributes.
  • Difficult to add data that is not represented in the visible HTML.
  • Nesting complex objects creates deeply nested attribute chains.

RDFa

Pros:

  • Supports multiple vocabularies in the same document via prefixes.
  • Well-supported by Drupal and some government/academic sites.
  • Tied to visible content like Microdata.

Cons:

  • Same template-modification challenges as Microdata.
  • Less widely used in the broader web development community.
  • Slightly more complex attribute syntax than Microdata.

When to Use Each Format

Use JSON-LD when:

  • You are building a new site and can choose freely. This is the default choice.
  • Your content is generated from a CMS, API, or database.
  • You want to keep structured data separate from your HTML.
  • You need to describe entities not visible on the page.
  • You want the simplest implementation path.

Use Microdata when:

  • Your CMS generates HTML with Microdata built in and you cannot easily add JSON-LD.
  • You want an absolute guarantee that structured data matches visible content.
  • You are working with a server-rendered site where visible content and structured data must stay in sync without additional tooling.

Use RDFa when:

  • You use Drupal, which has strong built-in RDFa support.
  • You need to mix multiple vocabularies (e.g., Schema.org and Dublin Core).
  • You work in an academic or government context where RDFa is the established standard.

Google’s Stated Preference

Google’s structured data documentation states:

Google recommends using JSON-LD for structured data whenever possible.

Google supports all three formats equally in terms of parsing, but their documentation, examples, tools, and testing interfaces all default to JSON-LD. The Rich Results Test shows JSON-LD examples first.

Practical Recommendation

Use JSON-LD unless you have a specific reason not to. It is the most maintainable format, has the broadest tooling support, and aligns with Google’s recommendation. The rest of this site uses JSON-LD in all examples.

If you are migrating from Microdata or RDFa to JSON-LD, you can run both formats simultaneously during the transition. Search engines will parse all structured data on the page regardless of format.