User-Agent Header Explained

What the HTTP User-Agent header does and when it's used.

Published October 14, 2026

User-Agent identifies the client software making the request, such as the browser, version and operating system.

How it works

Servers use it for analytics and bot detection, but it is easily spoofed and is being reduced in modern browsers.

The User-Agent header is part of the HTTP message and is case-insensitive in name.

In a real exchange

curl -i https://example.com/
User-Agent: Mozilla/5.0 (X11; Linux x86_64) Chrome/130.0
Where User-Agent appears.

Practical examples

The header

User-Agent: Mozilla/5.0 (X11; Linux x86_64) Chrome/130.0

Set or use it in code

const isBot = /bot|crawl|spider/i.test(req.get('User-Agent'))

Inspect it

curl -sI https://example.com | grep -i 'user-agent'

Common mistakes

  • Using it for security decisions
  • Browser sniffing instead of feature detection
  • Blocking unknown agents and breaking legitimate tools

Key takeaways

  • User-Agent: User-Agent identifies the client software making the request, such as the browser, version and operating system.
  • Check it in browser DevTools → Network.
  • Test with curl -I before deploying.

FAQ

Can I trust it?

No, any client can send any value.

Is User-Agent case sensitive?

Header names are case-insensitive; values may not be.

More HTTP articles