{"slug": "a-quick-way-to-visit-a-random-page-on-mdn", "title": "A quick way to visit a random page on MDN", "summary": "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.", "body_md": "# A quick way to visit a random page on MDN\n\nMaybe in the vein of Chris Coyier’s post on [A `/random` Route on a WordPress Site](https://chriscoyier.net/2023/11/29/a-random-route-on-a-wordpress-site/),\nI 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.\nIt’s pretty simple — it fetches MDN’s sitemap, parses the XML, and grabs a random URL then redirects to it.\n\n[https://mdn-random.kkipp.workers.dev](https://mdn-random.kkipp.workers.dev)\n\nI *love* [Copilot](https://github.com/features/copilot) for this kind of stuff. I had this thing built in less than 10 minutes.\nThis [Json2TS Raycast extension](http://www.raycast.com/gbarba/json2ts) was also pretty helpful for generating TS interfaces for the parsed XML.\n\nHere’s the complete code:\n\n``` python\nimport xml2js from \"xml2js\";\nexport interface Env {}\n\ninterface Sitemap {\n\turlset: Urlset;\n}\ninterface Urlset {\n\t$: $;\n\turl: UrlItem[];\n}\ninterface $ {\n\txmlns: string;\n}\ninterface UrlItem {\n\tloc: string[];\n\tlastmod: string[];\n}\n\nexport default {\n\tasync fetch(\n\t\trequest: Request,\n\t\tenv: Env,\n\t\tctx: ExecutionContext,\n\t): Promise<Response> {\n\t\tconst mdnSitemap = await fetch(\n\t\t\t\"https://developer.mozilla.org/sitemaps/en-us/sitemap.xml.gz\",\n\t\t);\n\t\t// parse xml sitemap\n\t\tconst sitemapString = await mdnSitemap.text();\n\t\tconst parsed = await (xml2js.parseStringPromise(\n\t\t\tsitemapString,\n\t\t) as Promise<Sitemap>);\n\n\t\t// pick a random url\n\t\tconst randomIndex = Math.floor(Math.random() * parsed.urlset.url.length);\n\t\tconst randomUrl = parsed.urlset.url[randomIndex].loc[0];\n\n\t\t// redirect to random url\n\t\treturn new Response(null, {\n\t\t\tstatus: 302,\n\t\t\theaders: {\n\t\t\t\tLocation: randomUrl,\n\t\t\t},\n\t\t});\n\t},\n};\n```\n\n", "url": "https://wpnews.pro/news/a-quick-way-to-visit-a-random-page-on-mdn", "canonical_source": "https://kevinkipp.com/blog/random-mdn-page/", "published_at": "2026-10-11 17:48:47+00:00", "updated_at": "2026-10-11 18:00:23.754344+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["MDN", "Cloudflare Workers", "GitHub Copilot", "xml2js", "Raycast", "Json2TS", "kkipp", "Chris Coyier"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/a-quick-way-to-visit-a-random-page-on-mdn", "markdown": "https://wpnews.pro/news/a-quick-way-to-visit-a-random-page-on-mdn.md", "text": "https://wpnews.pro/news/a-quick-way-to-visit-a-random-page-on-mdn.txt", "jsonld": "https://wpnews.pro/news/a-quick-way-to-visit-a-random-page-on-mdn.jsonld"}}