# Next.js structured data

> Render JSON-LD from a Next.js page, escape dynamic data safely, and validate Google rich result eligibility.

Canonical: https://scaplet.com/seo/nextjs/structured-data

Guide Next.js · Structured data

Render JSON-LD from a Next.js page, escape dynamic data safely, and validate Google rich result eligibility.

3 min

read

5

sources

Oct 24, 2026

updated

Scaplet Editorial Team

author

In one line

In Next.js, render JSON-LD in a native `<script type="application/ld+json">` inside the relevant `page.js` or `layout.js`. Build the object from the page’s real, visible data and escape `<` in serialized dynamic values to reduce script injection risk. Then validate the deployed URL; valid markup makes a page eligible for some rich results but does not guarantee display.

30-second check

## Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%2Fstructured-data%20(%22Next.js%20structured%20data%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%2Fstructured-data%20(%22Next.js%20structured%20data%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%2Fstructured-data%20(%22Next.js%20structured%20data%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%2Fstructured-data%20(%22Next.js%20structured%20data%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 3 parts, 3 minutes.

1. [Render JSON-LD with the App Router 01](#render-json-ld-with-the-app-router)
2. [Choose markup Google can use 02](#choose-markup-google-can-use)
3. [Validate the deployed HTML 03](#validate-the-deployed-html)

_01_Check it

## Render JSON-LD with the App Router

Next.js recommends [rendering](/glossary/rendering) [structured data](/glossary/structured-data) in a native script tag in `layout.js` or `page.js`. Put page-specific data in the page that describes it. For a product route, load the same product record used to render the visible name and description, then build [JSON-LD](/glossary/json-ld) from those values.

Next.js notes that `JSON.stringify` does not sanitize malicious strings used in XSS injection. Its guide demonstrates replacing `<` with the Unicode escape before placing JSON in the script. It suggests reviewing your organization’s recommended approach to sanitizing dangerous strings, or a community alternative to `JSON.stringify` such as `serialize-javascript`. Test the rendered response, not only the object in application code.

Product JSON-LD in a page component

```
const jsonLd = { "@context": "https://schema.org", "@type": "Product", name: product.name, image: product.image, description: product.description, } return ( <main> <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd).replace(/</g, "\\u003c"), }} /> <h1>{product.name}</h1> <p>{product.description}</p> </main> )
```

_02_Checklist

## Choose markup Google can use

First_2_
Start with a Google-supported rich result type that matches the page, such as Product for an actual product detail page. The sample above is Next.js's minimal example, not a complete rich result: Google's product [snippet](/glossary/snippet) markup requires `name` plus at least one of `review`, `aggregateRating`, or `offers`. Check the current feature documentation for required properties before adding markup.

Represent information that readers can see on that URL. Do not mark up ratings, availability, product attributes, or organization details that are absent or misleading on the page.

Next_2_
Keep values current. If price, availability, or product description changes in the rendered page, update the JSON-LD source from the same data record.

Use a native script tag. Next.js notes that `next/script` is optimized for executable JavaScript; JSON-LD is structured data, not executable code.

Then_1_
Do not add schema to every route from a global layout when its values describe only one route. Put it at the page or template level that owns the content.

**Schema is not a ranking shortcut**Google says structured data can make a page eligible for a rich result, but correct markup does not guarantee that Google will show one. Relevance, visibility, policies, and search context still matter.

_03_How it works

## Validate the deployed HTML

When a test passes but no rich result appears, first check the specific Google feature requirements and whether the page qualifies. A green test means the tool did not find technical errors; Google may still choose a plain result.

For framework-level crawl controls, see [Next.js XML sitemaps](/seo/nextjs/xml-sitemap) and [Next.js robots.txt](/seo/nextjs/robots-txt). For supported page types, see Google’s [Product structured data guide](/schema/product).

1. 01

### Inspect the rendered page

Open the production URL and check its HTML for one JSON-LD script with the expected type and values. Confirm it is present in the initial or [rendered DOM](/glossary/rendered-html) that Google can fetch.
2. 02

### Run a rich result test

Use Google’s Rich Results Test for types Google supports. Use Schema Markup Validator for general schema vocabulary checks that are outside Google rich result eligibility.
3. 03

### Review Search Console after deployment

Use URL Inspection to confirm Google can access the page and its structured data. Monitor relevant rich result reports for errors after templates or product data change.
4. 04

### Compare markup with the page

Check a product with variants, unavailable inventory, and missing optional images. Ensure markup describes the actual visible product state on each URL.

Sources · 5

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- nextjs.org
- google.com

1. 01 [How to implement JSON-LD in your Next.js application | Next.js Documentation](https://nextjs.org/docs/app/guides/json-ld) nextjs.org · checked 2026-10-24
2. 02 [General structured data guidelines | Google Search Central](https://developers.google.com/search/docs/appearance/structured-data/sd-policies) developers.google.com · checked 2026-10-24
3. 03 [Intro to structured data markup in Google Search | Google Search Central](https://developers.google.com/search/docs/appearance/structured-data/intro-structured-data) developers.google.com · checked 2026-10-24
4. 04 [Product snippet structured data | Google Search Central](https://developers.google.com/search/docs/appearance/structured-data/product-snippet) developers.google.com · checked 2026-10-24
5. 05 [Product structured data | Google Search Central](https://developers.google.com/search/docs/appearance/structured-data/product) developers.google.com · checked 2026-10-24

Questions

## Asked a lot.

3 questions people ask next, answered from the sources on this page.

_01_ Where should JSON-LD go in Next.js?

Next.js recommends a native `application/ld+json` script in the relevant `page.js` or `layout.js`. Put page-specific markup in the page that describes it.

_02_ Should I use next/script for JSON-LD?

No. Next.js recommends a native script tag because JSON-LD is structured data rather than executable JavaScript.

_03_ Why does my Next.js schema pass a test but not appear in Google?

A passing test checks many technical requirements but does not guarantee rich result display. Google also checks feature eligibility, page content, policy compliance, and search context.

## Keep learning

[All platform guides](/seo)

[Learn Next.js SEO Frameworks](/seo/nextjs) [Related Product schema Commerce](/schema/product) [Read next Next.js XML sitemap Frameworks](/seo/nextjs/xml-sitemap) [Do Run a free site audit Free, about two minutes](/site-audit)

More in Next.js SEO
[Next.js 404 page](/seo/nextjs/404) [Next.js AI crawlers](/seo/nextjs/ai-crawlers) [Next.js canonical tags](/seo/nextjs/canonical-tags) [Next.js Google Analytics](/seo/nextjs/google-analytics) [Next.js image SEO](/seo/nextjs/image-seo) [Next.js lazy loading](/seo/nextjs/lazy-loading) [Next.js noindex](/seo/nextjs/noindex) [Next.js redirects](/seo/nextjs/redirects) [Next.js robots.txt](/seo/nextjs/robots-txt) [Next.js structured data](/seo/nextjs/structured-data) [Next.js title and meta description](/seo/nextjs/title-and-meta) [Next.js XML sitemap](/seo/nextjs/xml-sitemap)

Terms on this page
[Rendering](/glossary/rendering) [Structured data](/glossary/structured-data) [JSON-LD](/glossary/json-ld) [Search snippet](/glossary/snippet) [Rendered HTML](/glossary/rendered-html)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

Run the free audit, then approve the fixes. Every change can be undone.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
