HSTS Builder

Generate HTTP Strict Transport Security headers with Apache, Nginx, and Express config examples.

freeworks offlinenothing uploaded
Input
Output

About hsts builder

HSTS Builder runs in the page as you use it. There is no input to submit and no result to fetch, because the whole thing happens on this side of the wire.

Paste a customer record into it if you need to. The record never leaves the machine you are sitting at.

You will find it under Web security, alongside 7 other tools for the same sort of job.

Supports preload eligibility and subdomain inclusion.

How to use it

01
Start it
Every control is on the tool itself. Keyboard shortcuts, where there are any, are listed beside it.
02
Watch it run
It updates in the page as you go. Nothing is sent anywhere, so it keeps working with the network off.
03
Close when done
Nothing is stored between visits. Reloading gives you a clean start rather than picking up where you left off.

Examples

One-year HSTS with preload eligibility
Build an HSTS header with 1-year max-age, subdomains, and preload. Eligible for the browser preload list
Input
maxAge: 31536000
includeSubDomains: true
preload: true
Output
# HTTP Strict Transport Security (HSTS)

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

# Duration: 1 year(s)
# Preload: Eligible for browser HSTS preload list

# Apache (.htaccess)
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"

# Nginx
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

# Express.js
app.use((req, res, next) => {
  res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload');
  next();
});

# To submit to the HSTS preload list:
# https://hstspreload.org/
# Requirements: max-age >= 31536000, includeSubDomains, preload

Questions

Does HSTS Builder work offline?+

Yes. It is JavaScript running in this tab, so once the page has loaded it needs nothing further from the network. Put the machine in flight mode and it carries on. Nothing you do here is sent anywhere, because there is nowhere for it to go.

Does it remember anything between visits?+

No. Reload the page and it starts from nothing. There is no account, no saved state and no cookie holding your last session. That is a deliberate trade: it cannot lose your data because it never keeps any.

Is it accurate?+

Timing comes from performance.now(), the high resolution clock the browser provides, rather than from setInterval, which drifts by a few milliseconds every tick and compounds over minutes. What can still shift things is the browser throttling a tab in the background, so leave it visible if the timing matters.

Does it make a sound?+

Where a sound makes sense, it is generated with the Web Audio API rather than loaded as a file, so there is nothing to download and nothing to block. Browsers refuse to start audio until you have interacted with the page, which is why the first press is what switches it on.

Can I use HSTS Builder on a phone?+

Yes. The controls are sized for touch and the layout collapses to one column on a narrow screen. Bear in mind that a phone locking its screen will suspend the page, and timing stops with it.