JSON-LD and Schema.org
JSON-LD (JSON for Linked Data) is the modern, preferred format for embedding structured data in an HTML page. Instead of scattering attributes across your visible markup like microdata does, you write one self-contained JSON block describing the page's structured facts.
The script tag
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"headline": "Understanding JSON-LD",
"author": {
"@type": "Person",
"name": "Jane Doe"
},
"datePublished": "2026-01-15"
}
</script>type="application/ld+json" tells the browser this is structured data, not executable JavaScript.
@context is almost always "https://schema.org", declaring which vocabulary the type names below come from.
@type names the schema.org type this object represents (Article, Product, Organization, and so on).
The script can be placed anywhere in the document — head or body — since it never renders visibly.
Why it's preferred over microdata
Aspect | JSON-LD | Microdata |
|---|---|---|
Separation of concerns | Fully separate from display markup | Interleaved with visible HTML attributes |
Ease of editing | One JSON block, easy to generate programmatically | Requires touching multiple elements throughout the page |
Risk of breakage | Independent of HTML/CSS refactors | Attributes can be accidentally removed during redesigns |
Google's stated preference | Recommended format | Supported, but not preferred for new projects |
Example: Product schema
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Product",
"name": "Wireless Mechanical Keyboard",
"image": "https://example.com/keyboard.jpg",
"description": "A compact 75% mechanical keyboard with hot-swappable switches.",
"offers": {
"@type": "Offer",
"priceCurrency": "USD",
"price": "89.00",
"availability": "https://schema.org/InStock"
}
}
</script>Example: Organization schema
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "Let Codes",
"url": "https://letcodes.example",
"logo": "https://letcodes.example/logo.png",
"sameAs": [
"https://twitter.com/letcodes",
"https://github.com/letcodes"
]
}
</script>Organization block describing the whole site alongside an Article block describing the current post.