Helmet is middleware that sets HTTP response headers for Node and Express applications. A default install applies multiple security-related headers with options to tune or disable each one.
Overview
Helmet helps secure Node and Express applications by configuring response headers such as Content-Security-Policy and Strict-Transport-Security. The design goal stated in the documentation is quick integration followed by low ongoing maintenance.
Calling the default middleware sets thirteen headers, including Content-Security-Policy with mergeable directives, Cross-Origin-Opener-Policy, Cross-Origin-Resource-Policy, Referrer-Policy, Strict-Transport-Security with max-age and preload options, X-Content-Type-Options, X-Frame-Options, and removal of X-Powered-By. Each header can be turned off or configured through dedicated options objects.
Content-Security-Policy support covers default directive bundles, report-only mode, nonce-friendly script-src functions, and disabling upgrade-insecure-requests during local HTTP development. Standalone sub-middleware functions exist for individual headers when you do not want the full bundle.
Helmet can run with Express, standalone Node.js, or other frameworks according to the project site. Validation of CSP strings is intentionally minimal; external CSP checkers are recommended for policy review.
Key features
- Default bundle of thirteen headers
- Configurable Content-Security-Policy
- Strict-Transport-Security defaults
- Cross-origin isolation headers
- Referrer-Policy and frame options
- Removes X-Powered-By by default
- Per-header standalone middleware
- Report-only CSP mode
Use cases
- Baseline headers for Express APIs
- Tuned CSP per application routes
- Disabling headers in local development
- HSTS for HTTPS-only deployments
- Clickjacking mitigation via frame policy