JSON-LD vs Microdata vs RDFa — Which Structured Data Format Should You Use?
When you set out to add structured data to your website, one of the first decisions you face is which format to use. The Schema.org vocabulary can be expressed in three different syntaxes: JSON-LD, Microdata, and RDFa. All three communicate the same information to search engines, but they differ significantly in how they are written, maintained, and supported.
This guide breaks down each format with real code examples, a side-by-side comparison, and clear recommendations so you can choose the right approach for your site.
JSON-LD (JavaScript Object Notation for Linked Data)
JSON-LD is a script-based format that embeds structured data as a standalone JSON object within a <script> tag on your page. It is completely decoupled from your HTML markup, meaning you can add, modify, or remove it without touching any of your visible content or templates.
JSON-LD Example: Local Business
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "LocalBusiness",
"name": "Riverside Coffee Roasters",
"image": "https://example.com/photos/storefront.jpg",
"telephone": "+1-503-555-0142",
"address": {
"@type": "PostalAddress",
"streetAddress": "123 Main Street",
"addressLocality": "Portland",
"addressRegion": "OR",
"postalCode": "97201"
},
"openingHoursSpecification": {
"@type": "OpeningHoursSpecification",
"dayOfWeek": ["Monday","Tuesday","Wednesday","Thursday","Friday"],
"opens": "06:00",
"closes": "18:00"
}
}
</script> Pros of JSON-LD
- Clean separation of concerns. Structured data lives in its own block, independent of your HTML. Frontend developers and SEO teams can work without stepping on each other.
- Easy to implement and maintain. Adding or changing schema is as simple as editing a JSON object. No need to refactor HTML templates.
- Google's recommended format. Google explicitly recommends JSON-LD in its developer documentation and has built its tooling around it.
- Dynamic generation. JSON-LD can be injected via JavaScript, making it ideal for single-page applications, client-side rendering, and tag managers like Google Tag Manager.
- Multiple entities per block. You can describe multiple related entities in a single script tag using
@graph. - No HTML modification required. You can add structured data to a page without changing a single line of the existing HTML.
Cons of JSON-LD
- Data duplication risk. Since JSON-LD is separate from your content, you may end up maintaining the same information in two places (the visible page and the JSON-LD block). If one changes without the other, inconsistencies can cause validation issues.
- Not visible in the DOM. For some debugging workflows, the separation from visible HTML can make it harder to verify that the data matches what the user sees.
- Bing's historical preference for other formats. While Bing now supports JSON-LD fully, it historically preferred Microdata and RDFa. This is no longer a practical concern for most sites.
Microdata
Microdata embeds structured data directly into your HTML elements using special attributes: itemscope, itemtype, and itemprop. The structured data is woven into the same tags that display your content to users.
Microdata Example: Local Business
<div itemscope itemtype="https://schema.org/LocalBusiness">
<h1 itemprop="name">Riverside Coffee Roasters</h1>
<img itemprop="image" src="https://example.com/photos/storefront.jpg"
alt="Riverside Coffee Roasters storefront" />
<p>Phone: <span itemprop="telephone">+1-503-555-0142</span></p>
<div itemprop="address" itemscope
itemtype="https://schema.org/PostalAddress">
<p>
<span itemprop="streetAddress">123 Main Street</span>,
<span itemprop="addressLocality">Portland</span>,
<span itemprop="addressRegion">OR</span>
<span itemprop="postalCode">97201</span>
</p>
</div>
</div> Pros of Microdata
- Single source of truth. Because the structured data is part of the HTML, the visible content and the machine-readable data are inherently synchronized. If the phone number changes in the HTML, the structured data changes automatically.
- No JavaScript dependency. Microdata is pure HTML, so it works everywhere, including environments where JavaScript is disabled or restricted.
- Good browser support. The Microdata API allows JavaScript to query microdata directly from the DOM, which can be useful for certain applications.
Cons of Microdata
- Cluttered HTML. Adding
itemscope,itemtype, anditempropattributes throughout your templates makes the HTML significantly more complex and harder to read. - Tight coupling with design. Changes to your HTML structure or CSS classes can accidentally break your structured data. Redesigns require careful re-mapping of microdata attributes.
- Difficult with complex schemas. Nested entities and multi-type schemas become unwieldy in Microdata. Deeply nested structures result in deeply nested HTML.
- Limited to visible content. You cannot easily include data that is not displayed on the page (like a logo URL or an organization's founding date) without adding hidden elements.
- Not Google's preference. While Google supports Microdata, it actively recommends migrating to JSON-LD.
RDFa (Resource Description Framework in Attributes)
RDFa is another inline format that uses HTML attributes to annotate content. It relies on vocab, typeof, and property attributes (among others) and is part of a larger family of semantic web technologies rooted in the W3C's Resource Description Framework.
RDFa Example: Local Business
<div vocab="https://schema.org/" typeof="LocalBusiness">
<h1 property="name">Riverside Coffee Roasters</h1>
<img property="image"
src="https://example.com/photos/storefront.jpg"
alt="Riverside Coffee Roasters storefront" />
<p>Phone: <span property="telephone">+1-503-555-0142</span></p>
<div property="address" typeof="PostalAddress">
<p>
<span property="streetAddress">123 Main Street</span>,
<span property="addressLocality">Portland</span>,
<span property="addressRegion">OR</span>
<span property="postalCode">97201</span>
</p>
</div>
</div> Pros of RDFa
- W3C standard. RDFa is a formal W3C recommendation, making it the most standards-compliant option for organizations that prioritize web standards.
- Multi-vocabulary support. RDFa can use multiple vocabularies (not just Schema.org) on the same page, such as Dublin Core, FOAF, or Open Graph. This is useful for academic, government, or library websites.
- Rich prefix system. The
prefixattribute allows compact, readable references to multiple vocabularies. - Strong Drupal integration. The Drupal CMS has excellent built-in support for RDFa, making it the natural choice for Drupal-based sites.
Cons of RDFa
- Steeper learning curve. RDFa's syntax is more complex than both JSON-LD and Microdata, with concepts like prefixes, CURIEs, and resource attributes that can confuse newcomers.
- Same inline limitations as Microdata. Like Microdata, RDFa clutters your HTML and tightly couples structured data with page design.
- Smaller community. Outside of Drupal and certain academic or government contexts, RDFa has a smaller user base, which means fewer tutorials, plugins, and tools.
- Not Google's preference. Google supports RDFa but recommends JSON-LD for all new implementations.
Side-by-Side Comparison
| Feature | JSON-LD | Microdata | RDFa |
|---|---|---|---|
| Syntax | JSON in a script tag | HTML attributes | HTML attributes |
| Separation from HTML | Fully separated | Inline / coupled | Inline / coupled |
| Google recommendation | Preferred | Supported | Supported |
| Ease of implementation | Easiest | Moderate | Most complex |
| Maintenance effort | Low | High | High |
| Dynamic / SPA support | Excellent | Limited | Limited |
| Multi-vocabulary | Schema.org only | Schema.org only | Multiple vocabularies |
| CMS plugin support | Excellent | Good | Drupal-centric |
| Data/HTML sync risk | Possible mismatch | Inherently synced | Inherently synced |
Which Format Should You Choose?
Choose JSON-LD if...
- You want the simplest implementation and lowest maintenance burden.
- You are building a modern website with any technology stack (React, Vue, Astro, Next.js, WordPress, Shopify, etc.).
- You need to inject structured data dynamically via JavaScript or a tag manager.
- You want to follow Google's explicit recommendation.
- You are working with an SEO team that manages schema independently from development.
This covers the vast majority of websites. If you are unsure, choose JSON-LD.
Choose Microdata if...
- You have an existing site that already uses Microdata extensively and migration is not cost-effective.
- You strongly prefer having structured data tightly bound to visible content to prevent sync issues.
- You are working in an environment where JavaScript is not available or not desired.
Choose RDFa if...
- You are using Drupal, which has excellent native RDFa support.
- You need to use multiple semantic vocabularies beyond Schema.org (Dublin Core, FOAF, Open Graph).
- Your organization requires W3C-standard semantic web markup for compliance or interoperability reasons.
- You are in an academic, government, or library context where RDFa is the established standard.
Migrating from Microdata or RDFa to JSON-LD
If your site currently uses Microdata or RDFa and you want to migrate to JSON-LD, the process is straightforward:
- Audit your existing markup. Use our schema validator to identify all structured data on your site and export it.
- Generate equivalent JSON-LD. For each page, create a JSON-LD block that contains the same information. Our JSON-LD Generator can help you build the new markup quickly.
- Add the JSON-LD to your pages. Place the
<script>tags in the<head>of each page. - Validate the new markup. Test every page to ensure the JSON-LD is valid and complete.
- Remove the old inline markup. Once the JSON-LD is validated and deployed, remove the Microdata or RDFa attributes from your HTML.
- Monitor in Search Console. Watch the Enhancements reports for any errors during the transition.
You can run both formats simultaneously during the migration. Google handles duplicate structured data gracefully as long as the information is consistent.
Can You Mix Formats?
Technically, yes. You can have JSON-LD on the same page as Microdata or RDFa. Google will parse all formats and merge the results. However, mixing formats increases complexity and the risk of conflicting data. The cleanest approach is to standardize on a single format across your site.
The one common exception is Open Graph tags (which use RDFa-like syntax in <meta> tags) alongside JSON-LD for Schema.org. This combination is standard practice and works well because the two serve different purposes: Open Graph is for social media platforms, while JSON-LD is for search engines.
Try it yourself
Build valid JSON-LD structured data for any schema type in minutes. No coding required — just fill in the fields and copy the output.
Open JSON-LD Generator