Skip to tool

Speculation Rules Generator

Generate speculation rules JSON for speculative loading.

Output will appear here…

How to Use This Tool

  1. Fill in Mode, URLs (one per line), and Eagerness. Each control is labeled; you do not need to paste a JSON blob.
  2. Click "Run" to run the tool in your browser.
  3. Read the result below the form and copy it if you need it in another app.

Learn More About Speculation Rules Generator

About Speculation Rules Generator

Generate speculation rules JSON for speculative prerendering and prefetching of pages.

About

Generate speculation rules JSON for speculative prerendering and prefetching of pages.
Generate speculation rules JSON for speculative prerendering and prefetching of pages.
Runs in browser
Yes
No signup required
Yes

Examples

Prerender moderate

Prerender moderate
Input
{
  "mode": "prerender",
  "urls": "/about\n/contact",
  "eagerness": "moderate"
}
Output
<script type="speculationrules">
[
  {
    "source": "document",
    "where": {
      "selector_matches": "a[rel=next]"
    },
    "eagerness": "moderate"
  },
  {
    "source": "list",
    "urls": [
      "/about",
      "/contact"
    ],
    "eagerness": "moderate"
  }
]
</script>

Prefetch conservative

Prefetch conservative
Input
{
  "mode": "prefetch",
  "urls": "/products\n/pricing",
  "eagerness": "conservative"
}
Output
<script type="speculationrules">
[
  {
    "source": "list",
    "urls": [
      "/products",
      "/pricing"
    ],
    "eagerness": "conservative"
  }
]
</script>

Immediate

Immediate
Input
{
  "mode": "prerender",
  "urls": "/home",
  "eagerness": "immediate"
}
Output
<script type="speculationrules">
[
  {
    "source": "document",
    "where": {
      "selector_matches": "a[rel=next]"
    },
    "eagerness": "immediate"
  },
  {
    "source": "list",
    "urls": [
      "/home"
    ],
    "eagerness": "immediate"
  }
]
</script>

Use Cases

  • Check speculation rules generator values while you draft a page, spreadsheet, or config.
  • Fill Mode, URLs (one per line), Eagerness and compare the result to a second source.
  • Keep sensitive inputs on-device — this page runs the calculation in the browser.

Frequently Asked Questions

Related tools: