Speculation Rules Builder

Build and validate prerender and prefetch rule sets for the Speculation Rules API.

Input

Related tools

What it does

Builds and validates Speculation Rules API JSON, the rule set browsers use to prefetch or prerender pages before a user clicks a link. In generate mode, paste one URL or URL pattern per line (use * or :param for a pattern, or prefix a line with not to exclude it) and get back document rules or a plain URL list, with an eagerness and action of your choice. In validate mode, paste an existing rule set (with or without the surrounding script tag) and get a verdict, a list of specific problems, and a plain-English description of what the rules actually do.

How to use it

Pick Generate or Validate at the top. For Generate, list your URLs or patterns, choose prefetch or prerender, pick an eagerness, and copy the resulting script tag straight into your page's head. For Validate, paste your JSON or full script tag and read the verdict: each finding names the exact key and what is wrong with it.

Why this one

Writing this JSON by hand means guessing at the where-clause grammar and eagerness values with no feedback until a real browser silently ignores a malformed rule. This tool builds the structure for you and, on the validate side, catches unknown keys, invalid eagerness values, and requirements used on the wrong rule type before you ship them. Your files and inputs never leave your device.

FAQ
Which browsers actually support the Speculation Rules API?
Chromium-based browsers (Chrome and Edge) support it today; prefetch shipped first and prerender followed. Firefox and Safari do not implement it, so treat it as a progressive enhancement: unsupported browsers simply ignore the script tag.
What does the eagerness setting actually change?
Eagerness controls how much user intent the browser waits for before firing the speculative request. Conservative waits for a strong signal like a pointer press, moderate uses the browser's own heuristic (typically a hover held briefly), eager fires on a lighter hover, and immediate fires the instant the rule matches, at the cost of more wasted bandwidth on links never followed.
How do I check whether a rule actually fired?
In Chrome, open chrome://process-internals and check the Preloading tab for the URL's status (its history shows exactly why a candidate was or was not used). Alternatively, open DevTools, go to the Application tab, and look under Speculative loads for each rule's match status and failure reason.

Keyboard shortcuts: press ? anywhere on this page to see them.