HTML input generator — labelled form fields with autocomplete and help text

Pick an input type and fill in the label, name and help text to get a form field whose label is linked by id, whose help text is announced through aria-describedby, and which has the autocomplete and validation attributes you choose.

Live demo · real result from this tool

Press Generate to create a result.

Processed on your device — nothing is uploaded.

How to use the HTML input generator

  1. Choose the Input type: text, email, password, number, tel, url, search, date and time types, color, range, file, checkbox, radio or textarea.
  2. Fill in the Label, the name and, for text-like types, a Placeholder.
  3. Add Help text (linked with aria-describedby) if people need a hint.
  4. Pick an Autocomplete token and tick Required if the field must be filled.
  5. Set the extra fields that appear for your type: min, max and step for numbers and dates; maxlength (0 = none) and pattern (regex) for text.
  6. Copy the code and try the field in the Preview.

What it does and when to use it

An input on its own is just a box. To be usable it needs a visible label that is programmatically linked to it, hints that screen readers can find, and attributes that let browsers and password managers help. Getting all of that right for each field is fiddly, and missing one link, such as a for that does not match the id, silently breaks it.

The generator produces one complete field at a time, which is useful when you add a field to an existing form or need an unusual type such as month or range. For a whole form from a list of fields, use the HTML Form Generator. For a dropdown with grouped options, use the HTML Select Dropdown Generator.

How it works

The id is made from the name: lower case, accents removed, other characters turned into hyphens. For most types the tool writes a label for the id, then the control. Checkbox and radio inputs are wrapped in their label instead. Placeholders are left out for color, range and file inputs, where browsers ignore them. textarea gets rows="4". Help text goes into a p with the id <id>-help. All text is HTML-escaped, so the apostrophe in “We’ll” becomes &#39;. Nothing leaves your browser.

Worked examples

The default work email field:

<label for="email">Work email</label>
<input type="email" id="email" name="email" placeholder="you@company.com" autocomplete="email" required aria-describedby="email-help">
<p id="email-help">We&#39;ll send the receipt here.</p>

A quantity between 1 and 10, no placeholder or help: <input type="number" id="qty" name="qty" min="1" max="10" step="1" required>.

A new password with help text “At least 12 characters.” and maxlength 64. The input ends with autocomplete="new-password" maxlength="64" required aria-describedby="new-password-help">.

A consent checkbox: <label><input type="checkbox" id="terms" name="terms" required> I agree</label>.

Limits and tips

  • Hidden fields such as min or pattern keep their values when you switch type, but only the attributes the chosen type supports are written, so a min left over from number is dropped from a text input.
  • pattern is a regular expression for the whole value. Explain the format in the help text too, since browser error messages are generic.
  • Browser validation runs only in the browser. Always check the data on the server as well.
  • A form also needs a submit button with type="submit"; the HTML Button Generator writes one.

Frequently asked questions

Why not just use a placeholder instead of a label?
A placeholder disappears as soon as someone starts typing, is often low in contrast, and is not reliably announced as the field's name. A label stays visible and, linked with for and id, also makes the label text clickable. The tool warns if you fill in a placeholder but no label.
What does aria-describedby do?
It links the field to the help paragraph, so a screen reader reads the hint, for example "We'll send the receipt here", after the label when the field gets focus. The tool gives the paragraph the id name-help and points the attribute at it.
Which autocomplete value should I choose?
The one that matches what the field asks for. email, tel, name, street-address and postal-code let browsers fill saved details. Use new-password on sign-up and password-change forms so password managers offer a strong password, current-password on log-in forms, and one-time-code for SMS codes.
Does the type change the keyboard on phones?
Yes. email shows a keyboard with @, tel a phone keypad, number and url their own layouts. The type also adds built-in checks; an email field rejects text without an @ when the form is submitted.
Why is the checkbox inside its label?
Wrapping the input in the label links them without needing for and id, and makes the label text a large click target. The tool still adds an id and name so your code and CSS can reach the field.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close