Online Subresource Integrity (SRI) Hash Generator
Subresource Integrity (SRI) is a security feature that allows browsers to verify that external resources such as JavaScript or CSS files loaded from a CDN have not been modified or tampered with. By adding an integrity attribute to your <script> or <link> tags, the browser ensures the file content matches the expected cryptographic hash before executing or applying it.
This online SRI Hash Generator helps you quickly generate SHA-256, SHA-384, and SHA-512 integrity hashes for local files, CDN URLs, or pasted content no setup required.
Contents
H2: Supported Hash Algorithms
- SHA-256 - Lightweight and commonly used
- SHA-384 - Recommended by many CDNs
- SHA-512 - Highest security level
Features of This SRI Hash Generator
- Supports JavaScript and CSS files
- Generate SHA-256, SHA-384, and SHA-512 hashes
- Works with local files, URLs, and text input
- One-click copy for
integrityattribute - Browser-based processing (no uploads stored)
- Fast and developer friendly
This tool allows you to generate Subresource Integrity (SRI) hashes using three different input methods. Using File, CDN URL, or Pasted Content. Upload a local JavaScript or CSS file, fetch a public CDN resource, or paste code directly. Select a hash algorithm (SHA-256, SHA-384, or SHA-512), and the tool instantly generates a browser ready integrity value fully in your browser with no data stored.
How to Use
- Upload a JavaScript or CSS file or CDN file URL or Paste raw file content
- Choose a hash algorithm (SHA-256, SHA-384, SHA-512)
- Generate the SRI hash instantly
From File
Upload a local JavaScript or CSS file to generate an SRI hash instantly in your browser. Files are processed locally and never uploaded.
Select algorithm:
Paste an HTML <script> tag and automatically generate the Subresource Integrity hash. The tool outputs a secure script tag with the correct integrity and crossorigin attributes, ready to use.
Auto-Generated SRI Integrity Tag:
Paste any HTML <script> or <link> tag to verify its SRI hash against the actual source file. The tool extracts the URL and integrity value, downloads the file locally in your browser, and checks whether the hash matches. If the SRI hash does not match, the tool generates the correct hash and regenerates an updated tag.
Enter a single <script> or <link> tag containing an integrity attribute.
A Subresource Integrity (SRI) hash is a cryptographic hash value that allows a web browser to verify that an external resource such as a JavaScript or CSS file loaded from a CDN has not been altered.
When a browser loads a file with an integrity attribute, it calculates the hash of the downloaded file and compares it with the provided SRI hash. If the values do not match, the browser blocks the resource from loading.
This mechanism protects websites from:
- Compromised CDN files
- Malicious code injection
- Accidental file modifications
Understanding the integrity and crossorigin Attributes
When you use SRI, you'll add two important attributes to your <script> or <link> tags:
- integrity: This attribute contains the cryptographic hash of the resource, prefixed by the hash algorithm used (e.g., sha-384-ADjU4obM7uGS0IMPG2fxxTV...). The browser uses this value to verify the fetched resource.
- crossorigin: This attribute specifies how the element handles CORS (Cross-Origin Resource Sharing). For SRI to work correctly, the browser needs to perform an anonymous cross-origin fetch, which requires setting
crossorigin="anonymous".
Example for a JavaScript file:
Example for a CSS file:
Why Use Subresource Integrity?
- Prevents loading of modified or compromised files
- Protects against supply-chain attacks
- Ensures trusted CDN content
- Improves overall website security
- Recommended for production websites
When Should You Update the SRI Hash?
You must regenerate the SRI hash whenever:
- The CDN file version changes
- The file content is updated
- You switch to a different CDN provider
If the file content changes even by one character the hash verification fails and the browser refuses to execute the file.
What is Subresource Integrity (SRI)?
SRI is a browser security feature that allows websites to verify that externally loaded resources such as JavaScript or CSS files have not been modified.
Which hash algorithm should I use for SRI?
SHA-384 is commonly recommended and supported by most CDNs, offering a good balance between security and performance.
Why does my SRI integrity check fail?
An integrity check fails when the file content changes or the hash does not match exactly. Even a small change in the file will cause the browser to block the resource.
Can I generate SRI hashes directly in the browser?
Yes. Modern browsers support the Web Crypto API, allowing SRI hashes to be generated securely without uploading files to a server.