Subresource Integrity (SRI) hash generator
Subresource Integrity lets a browser refuse a script or stylesheet from a CDN if its content has changed, which protects your site if the CDN is compromised. Paste the file’s exact content or choose the file, and this tool computes the integrity value (sha384 by default, as the W3C recommends) and builds the script or link tag with the integrity and crossorigin attributes filled in. You can also paste an existing integrity attribute to check whether it matches the file, using the same rules browsers apply.
Algorithm
Tag
Paste content or choose a file to get its integrity hash.
Check an integrity value
Paste an integrity attribute value to see whether it matches this file. Browsers only use the strongest algorithm listed.
How to use the SRI Hash Generator
- 1
Add the file
Choose the JavaScript or CSS file, or paste its exact content.
- 2
Pick the algorithm
Keep SHA-384 unless you have a reason to change it; SHA-256 and SHA-512 are also supported.
- 3
Add the URL
Type the URL you will load the file from to get a ready-to-paste tag.
- 4
Copy the tag
Copy the integrity value or the whole tag into your HTML.
How SRI hashes work
The integrity value is the hash algorithm’s name, a dash and the base64-encoded digest of the file’s exact bytes. A single changed byte, including a different line ending or a trailing newline, gives a completely different hash.
When an attribute lists several hashes, browsers only use the strongest algorithm present and accept the file if any hash of that algorithm matches. The checker follows the same rule, so a valid SHA-256 does not rescue a wrong SHA-512.
- integrity = "sha384-" + base64(SHA-384(file bytes))
When to use it
- Add integrity attributes to scripts and stylesheets loaded from a CDN.
- Check that a library file you downloaded matches the hash its publisher lists.
- Debug why a browser blocks a resource with an integrity error.
Limits
- The tool does not download files from URLs; choose the file or paste its content, because the hash must match the exact bytes served.
- Pasted text is hashed as UTF-8 with the line endings in the box. For an exact match, choose the file instead.
- Files up to 50 MB.
- Cross-origin resources need CORS (crossorigin="anonymous") for the browser to check integrity.
Privacy
Hashes are computed in your browser with the Web Crypto API. Your files are never uploaded.
Frequently asked questions
Which algorithm should I use?
SHA-384. The W3C SRI specification uses it in its examples and most CDNs publish sha384 values. SHA-256 and SHA-512 are also accepted by every modern browser.
Why does my hash not match the CDN’s?
The bytes differ. Common causes are a different version of the file, a minified versus unminified file, Windows line endings, or a missing trailing newline in pasted text. Choose the actual file for an exact hash.
Why is crossorigin="anonymous" needed?
Browsers only check integrity on cross-origin files fetched with CORS. Without the crossorigin attribute, the check fails and the file is blocked.
Can I list more than one hash?
Yes, separated by spaces. The browser uses the strongest algorithm present and accepts the file if any hash of that algorithm matches, which helps during file updates.
Does SRI work for files on my own domain?
Yes, but it matters most for files served by a third party such as a CDN, where you do not control the server.
Is my file uploaded?
No. The hash is calculated in your browser and nothing is sent to a server.
Related tools
People also use
- Phishing URL CheckerCheck a suspicious link for phishing tricks such as look-alike brand names and punycode, without opening it.
- SSH Key GeneratorMake an Ed25519 or RSA SSH key pair in OpenSSH format, with its fingerprint, without installing anything.
- 2FA / TOTP Code GeneratorGet 6-digit 2FA codes from a secret or QR code, create test secrets and check codes, all in your browser.
- Bcrypt & Argon2 Hash GeneratorCreate and check bcrypt and Argon2 password hashes, with parameters compared to OWASP guidance.
Last updated November 22, 2026 · How we build and test our tools