How to use Subresource Integrity Generator
- Select the final local script or stylesheet file, or paste its exact text. A selected file takes priority; pasted text is encoded as UTF-8.
- Choose SHA-256, SHA-384 or SHA-512 and the script or stylesheet tag. Enter the asset path/URL to use in that tag.
- Generate the integrity value and review its byte count and HTML draft. The URL is not fetched or checked.
- Download the tag or JSON record if needed. The delivered asset must retain the exact bytes; a cross-origin asset also needs the appropriate CORS response.
Example: Subresource Integrity Generator
Hash an empty JavaScript file with SHA-256 and draft its script tag.
Options
- Paste exact asset text (optional)
- Used only when no file is selected. UTF-8 bytes, including line endings, must match the deployed file. Up to 10 MiB.
- Local script or stylesheet
- One file up to 10 MiB. Its exact bytes are hashed without text decoding.
- Hash algorithm
- Choose SHA-256, SHA-384, SHA-512.
- HTML tag
- Choose Script, Stylesheet.
- Deployed asset URL or path
- Used in the tag only; never fetched. Ensure the deployed file has identical bytes.
Supported inputs and limits
- One file or UTF-8 encoded text up to 10 MiB.
- SHA-256/384/512 uses Web Crypto and requires HTTPS or localhost.
- A selected file is hashed as stored, including any BOM or line endings.
- The supplied HTTP(S) URL or relative path labels the tag only and is never fetched.
- Matching bytes and required cross-origin CORS access must be verified separately.
More details
The digest does not establish file safety or publisher trust.
Where your input is processed
This tool does not upload your inputs. See the limits for anything saved on your device.
Even a small byte change changes the digest
Line-ending conversion, minification or an added comment produces different bytes and therefore a different integrity value. Hash the final artifact rather than an earlier source file. A digest checks agreement with those bytes, not whether the JavaScript or stylesheet is safe.
Cross-origin use has another requirement
For an external asset, integrity checking also depends on the asset response permitting the required CORS access. This generator does not query that server, test the URL or publish the tag. Check the actual delivered resource in the consuming browser after deployment.
Questions about Subresource Integrity Generator
Does the URL field download the asset?
No. The page hashes a selected local file or the exact UTF-8 bytes of pasted asset text. The URL is used only in a generated HTML tag.
Will changing line endings affect the hash?
Yes. Hashing uses exact bytes, including a byte-order mark and line endings.
Why can an accurate cross-origin hash still fail?
The asset server also needs to permit the CORS request.