How to Add JSON-LD Structured Data to Any Website

Structured data is code you add to your pages so search engines can understand your content more precisely. Instead of guessing that a page is a recipe, a product listing, or a business address, structured data tells Google exactly what it's looking at.

The payoff is rich results — enhanced search listings with star ratings, prices, FAQ accordions, event dates, and more. Pages with rich results consistently see higher click-through rates than plain blue links.

JSON-LD vs Microdata vs RDFa

There are three formats for adding structured data to HTML. Google recommends JSON-LDand it's the one you should use. Here's why:

  • JSON-LD — A standalone <script>block you drop into your page. It doesn't touch your HTML markup, so it's easy to add, edit, and debug independently.
  • Microdata — Attributes (itemscope, itemprop) woven directly into your HTML tags. Tightly coupled to your markup, harder to maintain.
  • RDFa — Similar to Microdata but more verbose. Rarely used for SEO in practice.

JSON-LD keeps your structured data separate from your presentation layer. This makes it easier to maintain, less likely to break during redesigns, and simpler to generate dynamically from a CMS or database.

Common schema types

Organization

Defines your company's name, logo, social profiles, and contact information. Add this to your homepage. It helps Google build your Knowledge Panel.

LocalBusiness

For businesses with a physical location. Includes address, opening hours, phone number, and geographic coordinates. Essential for local SEO and Google Maps visibility.

Article

Used on blog posts and news articles. Includes headline, author, date published, and featured image. Can unlock Top Stories placement and article-specific rich results.

Product

For e-commerce product pages. Includes price, availability, review ratings, and SKU. Enables rich product snippets with price and stock status directly in search results.

FAQPage

Marks up question-and-answer pairs. Google previously displayed these as expandable accordions in search results, but since August 2023 FAQ rich results are limited to well-known government and health authority websites. FAQPage markup is still valid structured data and may benefit other search engines, but most sites will no longer see the accordion treatment in Google.

How to add JSON-LD to your page

Add a <script type="application/ld+json"> block anywhere in your HTML — typically in the <head> or at the end of the <body>. Here's a minimal Organization example:

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "name": "Your Company",
  "url": "https://example.com",
  "logo": "https://example.com/logo.png"
}
</script>

In Next.js or React, you can render this in your layout or page component. In WordPress, plugins like Yoast or Rank Math handle it automatically for most schema types. For custom types, add the script block via your theme's wp_head hook.

Testing structured data

Use Google's Rich Results Test(search.google.com/test/rich-results) to validate your markup. It shows which rich result types your page is eligible for and flags any errors or warnings. Google Search Console's Enhancements section also tracks structured data issues across your entire site.

Common mistakes

  • Marking up content that isn't visible — Google requires that structured data reflects content users can actually see on the page. Hidden content triggers manual penalties.
  • Missing required properties — Each schema type has required fields. A Product without name or an Article without headline will fail validation.
  • Wrong schema type — Using Article schema on a product page or LocalBusiness on a page with no address confuses search engines.
  • Stale data— Prices, availability, and event dates in structured data must match what's on the page. Outdated structured data can result in rich result removal.
  • Invalid JSON — A missing comma or unclosed bracket silently breaks the entire block. Always validate after editing.

Check your structured data instantly

AuditZap detects missing and invalid structured data on your pages — plus 20 more SEO checks.

Check your structured data