The minlength attribute sets the minimum number of characters a user can enter in a text-like <input> or a <textarea>. The value must be an integer of 0 or higher. Length is measured in UTF-16 code units (often the same as character count, but not always).
Supported input types: text, search, url, tel, email, and password. Pair with maxlength for an upper cap, and use min instead when you need a numeric or date/time floor. It does not imply required — an empty field can still submit unless you add that too.
Baseline · Widely available.
Not deprecated and not experimental. Stable across modern browsers since about July 2015.
Client validation only.
Browsers report tooShort when the value is too short after the user edits it. Always check length on the server.
Syntax
HTML Syntax
syntax.html
<input type="text" minlength="number">
<textarea minlength="number"></textarea>
number is a non-negative integer. If the attribute is missing or invalid, there is no minimum length.
Values
Attribute Values
One value type — a non-negative integer representing the minimum length:
Value
Description
Try it
number
Integer ≥ 0. Minimum UTF-16 code units (e.g. 8, 10)
Too short fails validation; too long is blocked by maxlength.
How It Works
minlength is the floor; maxlength is the ceiling.
Keep the order.minlength must be ≤ maxlength.
Works on both single-line inputs and <textarea>.
required ensures empty values are rejected as well.
Edge Cases & Pitfalls
Most surprises come from assuming empty fields are invalid, or mixing up min and minlength.
required
minlength does not imply required
An empty string is allowed unless you also set required. The minimum applies after the user enters a value.
compare
Do not confuse with min
minlength counts characters. min limits numeric or date/time values.
bounds
Keep minlength ≤ maxlength
If the floor is higher than the ceiling, no value can satisfy both constraints.
counting
UTF-16 code units
Some emoji use two units, so visible glyphs may not match value.length one-to-one.
security
Always re-check on the server
HTML length rules are UX helpers. Attackers can submit shorter strings without your form UI.
Compatibility
Browser Support
minlength is an HTML attribute for text inputs and textarea in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
minlength
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support minlength on text-like inputs and textarea.
96%Global support (approx.)
Google Chrome40+
Full support
Mozilla Firefox51+
Full support
Apple Safari10.1+
Full support
Microsoft Edge17+
Full support
Opera27+
Full support
Samsung Internet4+
Full support
Internet ExplorerNo
Not supported
minlengthWidely supported
Bottom line: Safe to use in modern browsers for character floors. Pair with required when empty values must also be rejected, and always validate on the server.
Remember
Key Takeaways
Role: require a minimum number of UTF-16 code units.
Elements: text-like <input> types and <textarea>.
Empty OK: add required if blank must also fail.
Not min: use min for number/date floors, not character count.
One line:minlength is the floor for typed text — empty still passes unless you add required.
Frequently Asked Questions
It sets the minimum number of characters a user can enter in a text-like input or a textarea. Length is measured in UTF-16 code units. Values that are too short fail constraint validation (tooShort).
input types text, search, url, tel, email, and password, plus textarea. It does not apply to number or date — use min for those.
No. minlength caps character count on text fields. min limits numeric or date/time values.
No. An empty field can still be submitted unless you also set required. minlength only applies once the user has entered a value.
Together they define a length range. minlength must be less than or equal to maxlength, or the value can never be valid.
No. It is client-side only. Always check string length on the server.