Designing Error Messages That Help
Write and place error messages that say what happened, why and what to do next, without losing the user's work.
Key takeaways
- State the problem and the next step in plain language, and skip blame and internal codes.
- Place field errors beside the field and add a summary when a form has several.
- Validate at a moment that helps, usually after a field is finished or on submit.
- Preserve what the user typed and make retrying safe.
- Announce errors in text that assistive technology can find, and log technical detail privately.
A helpful error message tells the user what went wrong, in words they understand, and what they can do about it, right where they're looking, without throwing away what they've already done. "Invalid input" fails on every count. "Enter a date in the future, such as next Tuesday" gives someone a way forward.
This guide covers wording, placement, timing, accessibility and the system errors you can't fully explain, with examples you can adapt.
Prevent the error first
The best message is the one nobody needs. Before polishing wording, remove causes:
- Accept reasonable formats. Strip spaces from card and phone numbers yourself.
- State rules before typing, such as password length or allowed file types.
- Use input types and constrained controls where they fit.
- Offer defaults and suggestions, such as "Did you mean example.com?" for a likely typo.
- Disable nothing silently. If a button can't work yet, let people press it and learn why, or explain beside it.
- Ask for confirmation, or better, offer undo for destructive actions.
The parts of a good message
An illustrative file upload message.
Not every message needs all four. "Enter your email address" beside an empty field is complete.
Write like a helpful person
| Instead of | Write |
|---|---|
| Invalid input | Enter a postal code, such as 12345 |
| Error 0x80 occurred | We couldn't save your changes. Try again |
| You failed to complete the form | Add your name to continue |
| Password does not meet criteria | Use at least 12 characters. You have 9 |
| Illegal characters | The name can't include / or \ |
| Oops! Something went wrong | Payment didn't go through. You haven't been charged |
Only promise things you know. Don't say "you haven't been charged" unless your system has confirmed it.
Be calm and neutral. Humor wears thin when someone has lost an hour of work. Avoid all capitals and exclamation marks. Use the same term the interface uses, so if the label says "Username," the error shouldn't say "login ID." Keep it short, and link to help only when extra explanation is needed.
Put it where it belongs
Match the display to the scope of the problem.
Avoid putting important errors only in a toast that fades after a few seconds. People may be looking elsewhere, reading slowly or using magnification. Modal pop-ups suit problems that must be resolved before anything else can happen, and little else.
Choose the moment
Validating on every keystroke scolds people before they've finished. A common, comfortable approach is:
- Check a field when the user leaves it, if they typed something.
- Check required fields on submit.
- Once a field shows an error, recheck as they type so the message clears quickly.
Positive hints, such as a password requirement that ticks off, can help. Server checks are still essential, because anything in the browser can be bypassed. Return server errors into the same inline pattern.
Make errors accessible
WCAG asks that input errors be identified and described in text, and that suggestions for fixing them be offered when known and safe to give. Color or an icon alone isn't enough.
<label for="email">Email</label>
<input id="email" type="email" autocomplete="email"
aria-invalid="true" aria-describedby="email-error">
<p id="email-error">Enter an email address, such as [email protected]</p> aria-invalid marks the field and aria-describedby ties the text to it, so a screen reader reads both. After a failed submit, move focus to an error summary or the first invalid field. For messages that appear without moving focus, a live region such as an element with role="alert" announces them; use it sparingly, since urgent interruptions pile up. Keyboard navigation and focus covers focus management, and color contrast and readability covers making the red text legible.
Built-in browser validation is convenient, but its wording and styling vary and the bubbles can disappear quickly, so many teams show their own messages.
Protect the user's work
Nothing sours an error like an empty form. Keep entered values after failure. Save drafts for long inputs. If a session expires, let the person sign in and return to where they were.
Make retries safe, especially for payments and orders. An idempotency key, a unique token sent with a request so the server processes it only once, prevents duplicates when someone presses the button again. Disable double submission while a request is in flight, but always restore the button if it fails.
Handle system and network errors
Sometimes the cause is yours and you can't explain it usefully. Say what didn't happen, whether anything was saved and what to try. Give a reference ID that support can look up in your logs.
Don't show stack traces, database messages, file paths or version numbers to visitors. They confuse people and help attackers. Record them privately, without logging passwords or card data. Sign-in and password reset forms need special care: wording such as "If that address has an account, we've sent a link" avoids revealing who is registered.
Error pages need the right HTTP status as well as friendly text. A missing page should return 404, not 200, and a temporary outage should return 503. See HTTP status codes explained and 404 Not Found. A good 404 offers search, key links and a way to report a broken one. Keep error pages light and independent of the systems that may have failed.
Handle special cases with care
Sign-in. Saying which part was wrong helps the user and also helps someone guessing accounts. A common compromise is "The email or password is incorrect," followed by a clear reset link. If an account is temporarily locked after repeated tries, say how to recover.
Payments. Banks often return limited reasons for a decline. Tell the buyer what you know, suggest checking the details or using another method, and mention contacting their bank. Keep the cart.
File uploads. State accepted types and the size limit before the picker opens. If one file in a batch fails, keep the successful ones and name the failed one.
Permissions. "Access denied" leaves people stuck. Say who can grant access or which account is signed in. Don't reveal that a private item exists to someone who shouldn't know.
Rate limits and outages. Say when to try again if you know. A server can send a Retry-After header, and the page can translate it into plain words.
Warnings that aren't errors. If the user may proceed, say so and make the consequence clear: "This file has the same name as one you uploaded. Replace it or keep both?" Reserve red and urgent wording for real failures, or people learn to ignore it.
Developers need messages too
The same discipline helps in APIs and command-line tools. Return an appropriate status code, a stable machine-readable error code, a human sentence, the field concerned and a request ID. A response might look like this:
{
"error": "invalid_field",
"field": "start_date",
"message": "start_date must be today or later",
"request_id": "example-7f3a"
} RFC 9457 defines a standard "problem details" format for HTTP APIs if you'd rather not invent your own. Whatever you choose, keep codes stable, because other programs will depend on them, while you stay free to improve the human wording. Interfaces built on your API can then map each code to a message written for their own users instead of showing yours raw.
In logs, include the time, the request ID and enough context to reproduce the fault, but no secrets. When a visitor quotes a reference from the error page, support should be able to find the matching entry quickly, which turns a vague complaint into a fixable bug.
Learn from what fails
Count which errors appear, on which fields and how often people give up afterward. Log the error type, not the personal data typed. A message that fires constantly usually signals a design problem: an unclear label, an unreasonable rule or a bug. In checkout, those are direct sources of lost orders, as in why shoppers abandon carts.
Keep a shared list of your messages so tone and terms stay consistent, and so translators get context. Leave room for longer text in other languages, and avoid assembling sentences from fragments.
Test them deliberately
Errors are rarely seen during development, so force them. Submit empty forms, paste very long text, use accented names, upload the wrong file, go offline mid-request, double-click the button and let a session expire. For each result, ask whether someone new would know what happened, whether their work survived and what they'd do next. If you can't answer all three, the message isn't finished.