Skip to content

Robots.txt Generator

Build a robots.txt file from a user agent, a disallow path, an optional allow path, and an optional sitemap URL. The page does not upload the file.

Result

Enter a user agent and a path

How to Use

  1. 1 Enter the user agent and the disallow path.
  2. 2 Enter an allow path and a sitemap URL, or leave them empty.
  3. 3 Copy the file text. It is not published.

Example Output

  • User-agent * and Disallow /admin is the shortest sample.

About This Tool

The sample uses User-agent *, Disallow /admin, Allow /, and a sitemap URL you can replace.

Using the Robots.txt Generator

The Robots.txt Generator builds the text of a robots.txt file from four fields. User agent starts as an asterisk. Disallow path starts as /admin. Allow path starts as a single slash. Sitemap URL starts as https://example.com/sitemap.xml. Choose Build robots.txt. The headline is 4 lines, and the label above it reads robots.txt. The text under the headline is four lines: User-agent with the asterisk, Disallow with /admin, Allow with the slash, and Sitemap with that URL. Each line puts a colon and a space between the field name and the value. The headline counts the lines that were actually written. Four filled fields produce 4 lines. Clearing an optional field lowers that count on the next build.

Allow and sitemap are omitted when you leave them empty. A run with only the user agent and the disallow path is two lines, and the headline reads 2 lines. The disallow path and the allow path must start with / and contain no spaces. A sitemap, when you type one, must start with http:// or https://. The user agent must be from 1 to 80 characters and must contain no spaces. The page does not upload the file. It does not place the text on a server. Copy result copies the lines, and you put them in a file yourself. The page does not choose a host path for that file and it does not compare the text with a file that already exists somewhere else. The result panel holds the lines until you copy them or reset.

The detail lines repeat the user agent and the disallow path. The steps say the user agent and the disallow path are written, the allow path and the sitemap are added when they were typed, and the page does not place the file on a server. Reset returns the four fields to the sample and the headline to Enter a user agent and a path. The file text is cleared, so copy it before you reset. The same four accepted values always rebuild the same lines, in the same order. Build the sample twice and the headline stays 4 lines, with User-agent first, Disallow second, Allow third, and Sitemap last. Change one field and build again to see only that part of the file move.

An empty user agent, a space inside it, or a value longer than 80 characters is rejected. An empty disallow path, a path that does not start with /, a space inside a path, or a path longer than 200 characters is rejected. A sitemap that is not empty and does not start with http:// or https:// is rejected. The rejection replaces the headline and clears the file text, so an old four-line sample does not stay under the error. Restore the field the message names and build again. The sample, with every field filled, is the quick way back to a four-line result you already understand.

What the Four Lines Are

The sample file is four lines because all four fields are filled. The first line is User-agent, then a colon, a space, and the asterisk. The second line is Disallow, then a colon, a space, and /admin. The third line is Allow, then a colon, a space, and /. The fourth line is Sitemap, then a colon, a space, and https://example.com/sitemap.xml. The headline counts those lines, so it reads 4 lines. Copy result copies the four lines, including the line breaks, not the words 4 lines.

The order is fixed. User-agent comes first. Disallow comes second. Allow comes next only when the allow field is not empty. Sitemap comes last only when the sitemap field is not empty. The page does not sort paths, and it does not add a second user-agent group. One user agent, one disallow path, and the two optional lines are the whole file this form can write.

How Optional Lines Are Kept or Dropped

The user agent and the disallow path are required, so those two lines are written on every successful run. The allow field is trimmed. If anything remains, it is checked as a path and written as an Allow line. If the field is empty, that line is skipped and the headline count falls by one. The sitemap field is trimmed. If anything remains, it is checked as an http or https URL and written as a Sitemap line. If the field is empty, that line is skipped too. Empty optional fields are not errors. They are omissions.

Alternate-language link tags are a different block of text. The Hreflang Generator builds hreflang link tags from a page URL, a language, and one alternate per line. It writes the link elements, and it does not submit them to a search engine. Use that page when you are marking language alternates. Use this page when you are writing User-agent, Disallow, and the optional Allow and Sitemap lines.

What the File Text Does Not Do

The page does not upload the file. The text stays in the result until you copy it or reset. Putting it where a crawler can read it is a step you take on your own host, under the name robots.txt, at the location your host expects. This form will not choose that location for you, and it will not check that a live file matches the text you just built.

The page also does not test whether a path is blocked for a particular crawler in the wild. Disallow /admin in the sample is the path you asked to write. It is not a report that a bot was turned away. Allow / is the path you asked to write beside it. The two lines can both appear. The page does not decide which one a crawler will honor. It writes the lines in the order above and stops.

The Sample Four Lines and a Two-Line File

Leave the fields on the sample and choose Build robots.txt. The headline is 4 lines. The text shows User-agent with an asterisk, Disallow with /admin, Allow with a slash, and Sitemap with https://example.com/sitemap.xml. Build again. The four lines match. Clear the allow field and the sitemap field, leave the user agent as an asterisk and the disallow path as /admin, and build. The headline is 2 lines. The text is User-agent with the asterisk, then Disallow with /admin. Allow and Sitemap are absent because those fields were empty.

Put the allow path back as / and leave the sitemap empty. Build. The headline is 3 lines, and the third line is Allow with the slash. There is no Sitemap line. A check of language codes is a different pass over text you already have. The Hreflang Validator checks hreflang tags you type, one per line. en is valid there. english is not. That page does not fetch a site. Use it when you are checking language tags. Use this page when you are building the robots.txt lines.

Paths, Agents, and URL Schemes

The user agent must be from 1 to 80 characters with no spaces. An asterisk is one character and is accepted. A name with a space is rejected with User agent must be from 1 to 80 characters with no spaces. A blank user agent uses that same message. The disallow path must start with / , contain no spaces, and be at most 200 characters. The message is Disallow path must start with / and contain no spaces. The allow path, when it is not empty, uses the same shape, and its message names the Allow path. admin without a leading slash is rejected. A path with a space in it is rejected.

A sitemap may be empty. A sitemap that is typed must start with http:// or https://, and it must be a URL the page accepts. Anything else is rejected with Sitemap URL must start with http:// or https://. The page does not add a scheme you forgot. example.com/sitemap.xml without the scheme fails that check. https://example.com/sitemap.xml passes it, which is why the sample includes the scheme. One bad field stops the build. The other good fields are not written out beside the error.

Lines People Assume Will Appear

A common miss is to leave Allow empty and still expect an Allow line. An empty allow field omits the line. Type / if you want Allow with a slash. Another miss is to type a sitemap without http:// or https:// and expect the page to repair it. The field is rejected. Another miss is to type the disallow path without the leading slash. The path is rejected before any line is written. Another miss is to put a space in the user agent. The agent is one token, up to 80 characters. Another miss is to treat the headline 4 lines as the file. The file is the block under the headline.

Structured data for a page is a different block. The Schema Markup Generator builds one JSON-LD object from a type, a name, and a description. It does not publish the markup or claim that a search engine will use it. Use that page when you are writing JSON-LD. Use this page when you are writing robots.txt lines from the four fields.

A Short File and a Rejected Sitemap

Set the user agent to an asterisk, the disallow path to /admin, and clear allow and sitemap. Build. Confirm 2 lines and the two field names User-agent and Disallow. Set the sitemap to https://example.com/sitemap.xml and build again. The headline becomes 3 lines, and the last line is Sitemap with that URL. There is still no Allow line. Clear the sitemap and type example.com/sitemap.xml without a scheme. Build. The headline reads Sitemap URL must start with http:// or https://, and the file text is cleared.

Put the scheme back, set the disallow path to admin with no leading slash, and build. The headline names the Disallow path and says it must start with / and contain no spaces. Restore /admin, set the user agent to two words with a space, and build. The user-agent message appears. Restore the asterisk, restore Allow as /, restore the sample sitemap, and build. The headline must read 4 lines, with the four sample lines in order, before you copy.

Saving the Inputs With the File Text

Copy result copies the file text. Write the four inputs beside it if you might rebuild the file later. For the sample, the note is user agent asterisk, disallow /admin, allow /, sitemap https://example.com/sitemap.xml, and the four lines. For a two-line run, write that allow and sitemap were left empty, so a later rebuild does not invent an Allow line you had dropped on purpose. The headline count is a quick check that the number of lines matches the number of fields you meant to fill.

The page does not keep the text after a reset. A single feed item is a different file to store nearby. The RSS Feed Generator builds one RSS 2.0 item from a title, a link, and a description. It does not publish the feed. Use that page when you are writing an RSS item. Use this page when you are writing robots.txt lines.

Text You Still Place Yourself

The lines are the file text. The page does not upload them. User-agent and Disallow are always present on a successful run. Allow appears when you typed a path. Sitemap appears when you typed a URL that starts with http:// or https://. The headline is the count of those lines, from 2 up to 4 for the combinations this form allows. A fifth line is not available, because there is no fifth field.

Read the copied text against the fields before you save it under the name robots.txt on a host. The sample, with every field filled, is the four-line block described above. A shorter block is what you get when you clear an optional field and build again. Either block is text in the result panel until you copy it. The panel is not a server.

Reading Each Line Before You Copy

Count the lines and compare them with the headline. Read User-agent and confirm the token has no space. Read Disallow and confirm the path starts with /. Read Allow only if you typed one, and confirm that path starts with / too. Read Sitemap only if you typed one, and confirm it starts with http:// or https://. For the sample, that reading is an asterisk, /admin, a slash, and https://example.com/sitemap.xml, and the headline is 4 lines. If the headline is an error, there is no file text to copy. Fix the field the message names and build again.

Cleaning a URL you might paste into the sitemap field is a separate pass. The URL Cleaner removes common tracking parameters from a URL and keeps the rest. A link with utm_source and id keeps id. That page does not open the link. Use it when you want those parameters dropped from a URL. Use this page when you want that URL, or any http or https URL you type, written as a Sitemap line.

Frequently Asked Questions

What does the sample produce?

Four lines: User-agent with an asterisk, Disallow with /admin, Allow with /, and Sitemap with https://example.com/sitemap.xml. The headline is 4 lines. Each line has a colon and a space between the name and the value. Copy result copies those four lines, not the headline count.

What happens when allow and sitemap are empty?

Those lines are omitted. The file is User-agent and Disallow, and the headline is 2 lines. Empty optional fields are not errors. Leave the disallow path filled, because that path is required. An empty disallow path is rejected before any line is written.

What must a path look like?

The disallow path, and the allow path when you type one, must start with / and contain no spaces. A missing slash or a space rejects the path before any line is written. The path may be at most 200 characters. admin without a leading slash fails the disallow check.

What must a sitemap look like?

It may be empty. If you type one, it must start with http:// or https://. Otherwise the page says Sitemap URL must start with http:// or https://. The page does not add a scheme you left off. The sample URL includes https:// for that reason.

Does the page upload the file?

No. It writes the lines in the result. Copy them and place the file yourself. The page does not upload the file, choose a host location, or check that a live file matches the text you built.

Can the user agent contain a space?

No. The user agent must be from 1 to 80 characters with no spaces. A space, a blank field, and a value over 80 characters are rejected with User agent must be from 1 to 80 characters with no spaces. An asterisk is one character and is accepted.

What does Copy result copy?

The file text, with one directive on each line. It does not copy the headline count, an error, or the waiting line. Copy before you reset. Reset restores the sample fields and clears the file text, and the headline returns to Enter a user agent and a path.

Can the form write two user-agent groups?

No. One run writes one user agent, one disallow path, and the optional allow and sitemap lines. The order is fixed. There is no fifth field, so there is no fifth line. A second group would be a second build you combine yourself.