Can Google process structured data added by JavaScript?

The Citead team, updated

In short. Google can process JavaScript-generated JSON-LD when it is present in the rendered DOM.

Definition: Yes. Google Search documents that it can understand and process structured data available in the DOM when it renders a page. It also documents that JSON-LD can be dynamically injected by JavaScript or an embedded widget.

Key facts

  • Google's JavaScript structured data guide says custom JavaScript can generate structured data or add information to server-side rendered structured data, provided the data is available in the DOM when Google renders the page.
  • Google's JavaScript SEO guide describes three processing phases: crawling, rendering, and indexing. Google uses the rendered HTML to index the page.
  • Google's structured data introduction says Google can read JSON-LD dynamically injected into a page's contents, including by JavaScript code or embedded widgets.

What does Google render?

Googlebot first fetches a URL and checks whether crawling is allowed. Google's JavaScript SEO guide says that blocked files or blocked pages are not rendered for JavaScript. For a page that reaches rendering, a headless Chromium instance renders the page and executes its JavaScript. Googlebot then parses the rendered HTML again for links, and Google uses that rendered HTML to index the page.

The guide describes the process as crawling, rendering, and indexing. It says pages with a 200 HTTP status code are sent to the rendering queue unless a robots meta tag or header tells Google not to index them. A non-200 response can cause rendering to be skipped. This makes the rendered result the relevant inspection point for markup inserted after the original HTTP response.

How can JavaScript add JSON-LD?

Google's JavaScript structured data guide shows a script that fetches structured data, creates an application/ld+json element, assigns the fetched text, and appends the element to the document head:

fetch('https://api.example.com/recipes/123')
  .then(response => response.text())
  .then(structuredDataText => {
    const script = document.createElement('script');
    script.setAttribute('type', 'application/ld+json');
    script.textContent = structuredDataText;
    document.head.appendChild(script);
  });

The same guide also describes Google Tag Manager and custom JavaScript as common ways to generate structured data. For server-side rendering, it says the structured data can be included in the rendered output. Its Tag Manager guidance recommends extracting values from the page with variables because duplicating them in Tag Manager increases the risk of a mismatch between page content and inserted structured data.

What must the markup describe?

Google's structured data introduction defines structured data as in-page markup describing the content of the page. It says not to add structured data about information that is not visible to the user, even when that information is accurate. Dynamic insertion therefore needs both a rendered JSON-LD element and page content that the markup describes.

The same documentation lists JSON-LD, Microdata, and RDFa as supported formats unless a feature guide says otherwise. It recommends JSON-LD in most cases and states that Google can read it when JavaScript or embedded widgets inject it into the page contents. The relevant feature documentation still determines the required properties and implementation rules.

How can you check the rendered result?

Google recommends testing the implementation with the Rich Results Test. Its JavaScript structured data guide recommends entering a URL instead of using the code input because JavaScript limitations can affect code-input tests, including CORS restrictions. If a structured data type is not supported by that test, Google says to inspect the rendered HTML. When the rendered HTML contains the structured data, the guide says Google Search can process it.

Google's JavaScript SEO guide also recommends the Rich Results Test or the URL Inspection Tool for checking rendered HTML. It states that Google cannot index content that is not visible in the rendered HTML, including content affected by web component rendering.

FAQ

Does JavaScript-generated JSON-LD need to be in the original HTML?

No. Google's documentation describes JSON-LD dynamically injected into page contents and structured data available in the DOM when the page is rendered. The rendered HTML must contain the resulting structured data.

Is a valid JSON-LD block enough for a Google rich result?

No. Google says the markup must follow the documentation for the relevant structured data feature, and the page must follow Google's structured data guidelines. The Rich Results Test checks supported types and can report syntax errors or missing properties.

Should a site use server-side rendering instead?

Google documents both client-side JavaScript injection and structured data in server-side rendered output. Its JavaScript SEO guide also says server-side or pre-rendering improves speed for users and crawlers, while some bots cannot run JavaScript.

Sources

  1. Google Search Central, "Generate structured data with JavaScript", 10 December 2025
  2. Google Search Central, "Understand the JavaScript SEO basics", 4 March 2026
  3. Google Search Central, "Introduction to structured data markup in Google Search", 10 December 2025

Check how a page reads to answer engines. Open the GEO score analyzer

Test a page and see what to fix first

The analysis usually takes less than 10 seconds and needs no account.

400,000+ pages scored in the public benchmark