JSON-LD (structured data in a script block)
What JSON-LD is, a small Product example, why Google recommends the format, how it differs from Microdata and RDFa, and where the block goes in a page.
On this page
JSON-LD is a W3C standard for writing linked data as JSON; on a web page it is a block inside a script element that states the page's facts, such as a product's name, price and GTIN, for machines.
What it means in practice#
JSON-LD is the form in which most shops hand product facts to search engines: a block of JSON that sits in the page next to the visible HTML instead of inside it. The W3C standard, JSON-LD 1.1 (a W3C Recommendation of 16 July 2020), describes it as "a lightweight syntax to serialize Linked Data in JSON" and notes that JSON-LD is 100% compatible with JSON. The format says how to write the facts. The words come from a vocabulary, on product pages almost always schema.org.
Three keywords appear in nearly every block:
| Keyword | What the W3C standard says it does | On a product page |
|---|---|---|
@context | Defines the short names used in the document | https://schema.org/ |
@type | Sets the type of a node | Product, Offer, Brand |
@id | Uniquely identifies a node | Optional; links related items on a page |
A small Product example#
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "Northpeak Trail 400 Headlamp, Black",
"image": "https://www.northpeak.example/images/trail-400-black-1x1.jpg",
"offers": {
"@type": "Offer",
"price": 49.95,
"priceCurrency": "USD"
}
}
</script>This block holds what Google requires for a merchant listing: a name, an image and an offer with a price above zero and a currency. The guide to Product schema markup adds brand, GTIN, shipping details, the return policy and variants.
Why Google recommends it#
Google supports three formats for structured data and recommends JSON-LD "if your site's setup allows it, as it's the easiest solution for website owners to implement and maintain at scale", and less prone to user errors (Google Search Central). It accepts any of the three as long as the markup is valid. Bing lists JSON-LD among the formats it supports for schema.org and says its crawlers do not prefer one specification over another.
JSON-LD, Microdata and RDFa#
| Format | How it is written | Where Google says it goes |
|---|---|---|
| JSON-LD | One block of JSON in a script element, not interleaved with the user-visible text | In the head or the body |
| Microdata | Attributes on the HTML tags that hold the content | Typically the body, possible in the head |
| RDFa | Attributes on the HTML tags that correspond to the visible content | Commonly both head and body |
The practical difference: Microdata and RDFa label the text a visitor reads, while JSON-LD repeats the facts in a second place. A template can print JSON-LD without touching the layout, but the block and the page can drift apart, and Google's guidelines say not to mark up content that is not visible to readers.
Where it goes in the page#
- Element. The W3C standard embeds JSON-LD in HTML with a
scriptelement whosetypeisapplication/ld+json. A page may hold several such blocks. - Position. Google reads the block in the
heador thebody, and can read JSON-LD that is injected dynamically. - Product pages. Google still asks merchants for Product markup in the initial HTML, because markup generated with JavaScript can make Shopping crawls less frequent and less reliable. Merchant Center requires the markup in the HTML returned from the web server.
- Syntax. The W3C standard tells authors to avoid or escape character sequences that HTML could confuse with the start or end of a script or a comment. Google's Rich Results Test ignores comments in JSON-LD but warns that they might cause errors in actual use.
- Context. Google reports an invalid or unsupported
@contextvalue as an error and does not support custom remote contexts; use schema.org.
To check a live product page, use the product schema checker at the top of this page: it reads the page's JSON-LD and checks it against what Google needs for product results and merchant listings.
Questions
Where does JSON-LD go on a product page?
In a script element of type application/ld+json. Google reads it in the head or the body. For product pages, Google and Merchant Center ask for it in the HTML the server returns, not added later with JavaScript.
Is JSON-LD required, or can I use Microdata?
Google supports JSON-LD, Microdata and RDFa and accepts any of them when the markup is valid. It recommends JSON-LD where your site's setup allows it. Bing says its crawlers do not prefer one specification over another.
Does JSON-LD have to match what the page shows?
Yes. Google's guidelines say not to mark up content that is not visible to readers, and Merchant Center requires structured data to match the values shown to the user.
Sources
- JSON-LD 1.1: A JSON-based Serialization for Linked DataW3Cchecked 23 November 2026
- Introduction to structured data markup in Google SearchGoogle Search Centralchecked 23 November 2026
- Merchant listing (Product, Offer) structured dataGoogle Search Centralchecked 23 November 2026
- Set up structured data for Merchant CenterGoogle Merchant Center Helpchecked 23 November 2026
- Rich result error messages and solutionsSearch Console Helpchecked 23 November 2026
- Rich Results TestSearch Console Helpchecked 23 November 2026
- Marking up your site with structured dataBing Webmaster Tools Helpchecked 23 November 2026
- How to write product descriptions: structure, examples and channel rulesGuides
- hreflangGlossary
- Hreflang for online shops: languages, countries and x-defaultGuides
- Meta title and description length for product pagesGuides
- Product description examples and a template you can copyGuides
- URL slugGlossary
- URL slugs for product pages: how to write SEO-friendly URLsGuides