cd /news/developer-tools/a-quick-way-to-visit-a-random-page-o… · home › topics › developer-tools › article
[ARTICLE · art-149248] src=kevinkipp.com ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

A quick way to visit a random page on MDN

Developer kkipp built a Cloudflare Worker that redirects visitors to a random page on MDN by fetching MDN's gzipped sitemap at https://developer.mozilla.org/sitemaps/en-us/sitemap.xml.gz, parsing the XML with xml2js, and issuing a 302 redirect to a randomly indexed URL. The tool is live at https://mdn-random.kkipp.workers.dev, and the author said GitHub Copilot let him build it in less than 10 minutes, with the Json2TS Raycast extension used to generate TypeScript interfaces for the parsed XML.

read1 min views1 publishedOct 11, 2026
A quick way to visit a random page on MDN
Image: source

Maybe in the vein of Chris Coyier’s post on A /random Route on a WordPress Site, I found myself kinda interested in being able to just go to a random page on MDN. I didn’t find an obvious existing feature for this, so I hacked one together. It’s pretty simple — it fetches MDN’s sitemap, parses the XML, and grabs a random URL then redirects to it.

https://mdn-random.kkipp.workers.dev

I love Copilot for this kind of stuff. I had this thing built in less than 10 minutes. This Json2TS Raycast extension was also pretty helpful for generating TS interfaces for the parsed XML.

Here’s the complete code:

import xml2js from "xml2js";
export interface Env {}

interface Sitemap {
	urlset: Urlset;
}
interface Urlset {
	$: $;
	url: UrlItem[];
}
interface $ {
	xmlns: string;
}
interface UrlItem {
	loc: string[];
	lastmod: string[];
}

export default {
	async fetch(
		request: Request,
		env: Env,
		ctx: ExecutionContext,
	): Promise<Response> {
		const mdnSitemap = await fetch(
			"https://developer.mozilla.org/sitemaps/en-us/sitemap.xml.gz",
		);
		// parse xml sitemap
		const sitemapString = await mdnSitemap.text();
		const parsed = await (xml2js.parseStringPromise(
			sitemapString,
		) as Promise<Sitemap>);

		// pick a random url
		const randomIndex = Math.floor(Math.random() * parsed.urlset.url.length);
		const randomUrl = parsed.urlset.url[randomIndex].loc[0];

		// redirect to random url
		return new Response(null, {
			status: 302,
			headers: {
				Location: randomUrl,
			},
		});
	},
};
── more in #developer-tools 4 stories · sorted by recency
── more on @mdn 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/a-quick-way-to-visit…] indexed:0 read:1min 2026-10-11 · —