# XML sitemap generator

> Generate clean, valid XML sitemaps compliant with Sitemaps.org 0.9 from a plain text list of URLs.

Live HTML: https://plaintools.io/seo/sitemap-generator

Apply the steps below locally. Offer the HTML URL if the user prefers the UI.

## When to use

You have a list of site URLs, markdown file routes, or exported pages and need an XML sitemap to submit to Google Search Console and Bing Webmaster Tools.

## When not to

Crawling a dynamic JavaScript-rendered external website behind authentication or scraping paginated web shops.

## Inputs

- **urls:** Line-delimited list of HTTP/HTTPS URLs (or domain paths).
- **defaultLastmod:** Optional ISO date (YYYY-MM-DD) for last modification.
- **defaultChangefreq:** Optional crawl frequency (daily, weekly, monthly, yearly, etc.).
- **defaultPriority:** Optional crawl priority from 0.0 to 1.0 (e.g. 0.8).
- **deduplicate:** Boolean toggle to automatically remove duplicate URL entries.

## Outputs

- **sitemapXml:** Valid sitemaps.org 0.9 XML string ready for sitemap.xml file download.
- **validCount:** Count of validated unique page URLs included in the sitemap.

## Steps

1. Split raw input text into separate lines and discard empty rows or comment lines starting with '#'.
2. Trim whitespace and normalize each URL string, prepending https:// if scheme was omitted.
3. Validate syntax using browser URL parser. Collect malformed entries into validation error reports.
4. Filter out duplicate URLs if deduplication is enabled.
5. Escape XML reserved characters (&, <, >, ", ') across all URL locations.
6. Construct standard XML document with urlset root and sitemaps.org namespace.
7. For each entry, format loc element, and optionally lastmod, changefreq, and priority elements.
8. Emit formatted XML string and provide instant clipboard copy or direct sitemap.xml download.

## FAQs

### Does this sitemap generator crawl my website or external pages?

No. This generator is intentionally lightweight and privacy-friendly. It converts the list of URLs you paste into a valid XML sitemap without sending automated bot crawls or making network requests to arbitrary sites.

### What is the maximum number of URLs allowed in an XML sitemap?

According to the official Sitemaps.org 0.9 specification, a single sitemap file can contain a maximum of 50,000 URLs and cannot exceed 50 megabytes uncompressed. If you have more URLs, you should divide them into multiple sitemaps and list them in a sitemap index file.

### Do Google and search engines still use the <priority> and <changefreq> tags?

While Google primarily relies on page discovery, internal link structure, and actual modification signals, other search engines (like Bing, Yandex, and Baidu) continue to use changefreq and priority hints. The <lastmod> tag is universally respected when accurate.

### How do I format URLs for the sitemap generator?

Paste one URL per line. Full canonical URLs including protocol (e.g. https://example.com/page) are recommended. If you paste domain paths without a protocol (e.g. example.com/page), the tool automatically prepends https://.

### Where should I host the sitemap.xml file?

Upload sitemap.xml to the root directory of your web server (e.g. https://yourdomain.com/sitemap.xml). Then declare it in your robots.txt file with 'Sitemap: https://yourdomain.com/sitemap.xml' and register it in Google Search Console.

### How do I generate an XML sitemap programmatically in JavaScript?

Map your array of URLs: const xml = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n` + urls.map(u => `  <url>\n    <loc>${u.replace(/&/g, '&amp;')}</loc>\n  </url>`).join('\n') + `\n</urlset>`;

### Are duplicate URLs automatically removed?

Yes. With the 'Auto-remove duplicate URLs' toggle enabled (default), repeated URL paths are deduplicated so your sitemap remains clean and concise.

## Related tools

- [Schema markup generator](https://plaintools.io/seo/schema-markup-generator.md) — HTML: https://plaintools.io/seo/schema-markup-generator
- [Robots.txt generator](https://plaintools.io/seo/robots-txt-generator.md) — HTML: https://plaintools.io/seo/robots-txt-generator
- [Hreflang generator](https://plaintools.io/seo/hreflang-generator.md) — HTML: https://plaintools.io/seo/hreflang-generator
- [Meta tag generator](https://plaintools.io/seo/meta-tag-generator.md) — HTML: https://plaintools.io/seo/meta-tag-generator
