Grade your security headers, A+ to F.
Scans any URL for HSTS, CSP, X-Frame-Options and the rest, flags dangerous values and information disclosure, then returns a single letter grade with ranked fixes. Set a minimum grade and it fails your build.
Why it matters
A handful of response headers do a lot of quiet work. HSTS forces every connection over TLS. A well-formed Content-Security-Policy closes off most cross-site scripting. X-Frame-Options stops clickjacking. None of them need application changes, yet plenty of live sites ship without them.
The subtle failures are the ones a manual check misses: a CSP that allows unsafe-inline and undoes its own protection, or a Server header leaking an exact version that hands attackers a shortlist of known exploits. This tool weighs each header, penalises the dangerous values, and turns the result into one grade you can gate a deploy on.
How grading works
High-weight headers are HSTS and CSP. Medium weight covers X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy and Cross-Origin-Opener-Policy. Cross-Origin-Resource-Policy is low weight. Dangerous CSP values and information disclosure both cost points.
Install
npx @trustyourwebsite/security-headers https://example.com
# Or install globally
npm install -g @trustyourwebsite/security-headers
security-headers https://example.com
Common options
--formatjson, text, table or csv. Table is the default.--ciExit code 1 when the grade is below the threshold.--min-gradeMinimum grade for CI mode. Default B.--follow-redirectsFollow HTTP redirects. On by default.--outputWrite the report to a file.--timeoutRequest timeout in milliseconds. Default 10000.security-headers https://example.com --ci --min-grade B
# JSON report saved to a file
security-headers https://example.com --format json --output report.json
→ also usable as a library via checkHeaders()