Free SRI Hash Generator
Generate Subresource Integrity hashes for external scripts. Free, fast, and works entirely in your browser with no sign-up required.
Updated
SRI Generator
Generate Subresource Integrity (SRI) hashes for scripts and stylesheets to protect against CDN compromises and supply-chain attacks.
SRI Hash Generator
Drag & drop JS/CSS files or click to browse
Frequently Asked Questions
What is the SRI Hash Generator?
The SRI Hash Generator is a free online tool that creates Subresource Integrity hashes for external scripts and stylesheets to protect against CDN compromise.
Is the SRI Hash Generator free?
Yes, it is completely free with no registration required. All hash generation happens client-side in your browser.
Why do I need SRI hashes?
SRI hashes ensure that external scripts loaded from CDNs have not been tampered with. If the file changes, the browser will block it from executing.
Is my data safe with this tool?
Absolutely. The SRI Hash Generator processes everything client-side in your browser. No data is uploaded to or stored on any server. Your content remains private on your device at all times.
Does the SRI Hash Generator work on mobile devices?
Yes, the SRI Hash Generator is fully responsive and works on smartphones and tablets. You can use it on any device with a modern web browser -- no app download required.
Do I need to create an account to use this tool?
No account or registration is needed. Simply open the SRI Hash Generator in your browser and start using it immediately. There are no sign-up walls or usage restrictions.
How do I use the SRI Hash Generator?
Simply enter your input in the provided field, adjust any settings to your preference, and the tool will process it instantly. You can then copy the result to your clipboard or download it.
Which browsers are supported?
The SRI Hash Generator works in all modern browsers including Chrome, Firefox, Safari, Edge, and Opera. For the best experience, use the latest version of your preferred browser.
What is the difference between SHA-256, SHA-384, and SHA-512 for SRI hashes?
All three are SHA-2 hash functions and all are valid for Subresource Integrity; the difference is digest length and the strength margin it gives you. SHA-256 produces a 256-bit hash, SHA-384 a 384-bit one, and SHA-512 a 512-bit one, so the integrity attribute gets progressively longer. The W3C specification names SHA-384 as the recommended default because it balances a strong security margin against attribute length, which is why this tool selects it by default. You are not locked in, though: you can even list several hashes in one attribute, like integrity="sha384-... sha512-...", and the browser will use the strongest algorithm it understands. Generate your file here and the tool returns all three digests at once, with the one matching your selected algorithm marked as primary so you can copy whichever you prefer.
Why does an SRI-protected script need the crossorigin="anonymous" attribute?
Subresource Integrity can only verify a file the browser is allowed to read, and for a resource loaded from a different origin than your page, that permission comes from CORS. Adding crossorigin="anonymous" makes the browser send an anonymous cross-origin request, and as long as the host returns the right CORS headers the response becomes readable so its hash can be computed and compared. Leave the attribute off and the browser treats the cross-origin response as opaque: it cannot read the bytes, cannot verify the integrity hash, and refuses to load the resource, so your script or stylesheet silently fails. That is why every script and link tag this tool generates already includes crossorigin="anonymous". Paste your file or URL, copy the finished tag, and the CORS attribute is handled for you.
What happens in the browser when an SRI hash does not match the file?
When you attach an integrity attribute, the browser downloads the resource, hashes the bytes with the named algorithm, and compares the result to the value you supplied. If they match, the file runs normally. If they differ for any reason, the file was modified, replaced, or the CDN was compromised, the browser refuses to use it entirely: a blocked script never executes and a blocked stylesheet never applies, and a network error is reported in the console. This hard failure is the whole point, turning a silent supply-chain compromise into a visible, enforced block rather than letting tampered code run. Because a blocked resource can break a page, this tool can also emit an onerror fallback that swaps in a local copy, so the page degrades gracefully. Generate a hash above and add it to your tag to enable this protection.
How do I update an SRI hash when the CDN file changes?
An SRI hash verifies one exact snapshot of a file, so any legitimate change breaks it on purpose. If a library ships a new version, the CDN serves a patched build, or you bump a pinned URL, the bytes differ and the old hash will no longer match, causing the browser to block the resource until you regenerate. The fix is to compute a fresh hash for the new file and replace the value in your integrity attribute. To avoid surprise breakage, pin to a versioned, immutable URL rather than a floating latest path, so the file only changes when you deliberately point at a new version. When that happens, paste the updated file or its URL into this tool, generate the new hash, and copy the replacement tag straight into your HTML.
Why does batch CDN mode sometimes fail to fetch a remote file?
Pasting content or uploading a file is hashed entirely in your browser, so nothing leaves your machine. Batch mode is different: to hash a remote asset it first has to download that file, and that fetch is a real cross-origin request subject to the host's CORS policy. If the CDN or server does not return permissive CORS headers, the browser blocks the response your code cannot read, and the fetch fails even though the file exists and the URL is correct. Some hosts also rate-limit or refuse automated requests. This is a limitation of the remote server, not the hash itself, since the same file pasted in hashes fine. For guaranteed results, download the file and use the paste or upload tab instead. Try the batch presets here for popular libraries, and fall back to paste mode when a URL is blocked.
Related Tools
Free Hash Verifier Online
Verify file integrity by comparing hash checksums. Free, fast, and works entirely in your browser with no sign-up required.
Free Security Headers Analyzer
Check website security headers and get improvement suggestions. Free, fast, and works entirely in your browser with no sign-up required.
Free Encryption/Decryption Tool
Encrypt and decrypt text using AES, DES, and other algorithms. Free, fast, and works entirely in your browser with no sign-up required.
Free HMAC Generator Online
Generate HMAC signatures for API authentication using multiple hashing algorithms. Free, fast, and works entirely in your browser with no sign-up required.
About the SRI Hash Generator
The SRI Hash Generator creates Subresource Integrity hashes for the external JavaScript and CSS files your pages load from a CDN or third-party host. Paste the file's contents, drop the file in, or queue a list of URLs, and the tool returns the cryptographic integrity value plus a ready-to-paste <script> or <link> tag. It is built for front-end developers, site owners, and security engineers who pull libraries like jQuery, Bootstrap, or React from a public CDN and want the browser to refuse anything that has been swapped out underneath them.
Hashing happens in your browser with the Web Crypto API. When you paste content or upload a file, nothing is sent anywhere — there is no account, no upload step, and no server copy of your code. The batch mode is the one exception: to hash a remote URL it has to fetch that file, so those requests leave your machine and can be blocked by the host's CORS policy. For guaranteed results, paste or upload instead.
What Subresource Integrity is and why it matters
Subresource Integrity is a browser security feature defined by the W3C. You attach an integrity attribute containing a base64 hash to a script or stylesheet tag. The browser downloads the file, hashes it, and compares: if the hashes match the resource runs, and if they differ — because the file was modified, replaced, or the CDN was compromised — the browser blocks it entirely.
That guard matters because a single tampered library can run arbitrary code on every page that includes it. Supply-chain attacks on CDNs and npm-backed assets are a recurring threat, and SRI turns a silent compromise into a hard failure the browser enforces for you. One caveat: SRI verifies a fixed snapshot, so the hash must be regenerated whenever the file legitimately changes (a new version, a patched build), and it cannot be used for inline scripts whose content is dynamic.
How to generate a hash
- Paste content — drop in the raw JS or CSS, choose an algorithm, and generate. Pasted content is labeled
inline-contentin the output; replace that with your realsrc/href. - Upload files — drag and drop, or browse for one or more
.js,.css, or.mjsfiles. Each file is hashed locally and its byte size is shown. - Batch / CDN mode — paste a list of URLs (one per line) to fetch and hash several remote assets at once. The tool also lists presets for popular libraries such as jQuery, Bootstrap, React, Vue, Alpine.js, Axios, and Font Awesome for reference.
Every result includes all three hashes — SHA-256, SHA-384, and SHA-512 — so you can copy any of them, with the one matching your selected algorithm marked as primary.
Choosing an algorithm and the crossorigin attribute
- SHA-384 is the default and recommended choice under the W3C specification — a sensible balance of strength and length. SHA-256 and SHA-512 are equally valid, and you can list several hashes in one attribute (
integrity="sha384-... sha512-...") so the browser uses the strongest it understands. crossorigin="anonymous"is required. Cross-origin resources need CORS to be readable for integrity checking, so the generated tags always include it. Without it, the browser cannot verify the hash and the resource fails to load.- An optional fallback pattern adds an
onerrorhandler that swaps in a local copy if the integrity check blocks the CDN file, so a tampered or unreachable asset degrades gracefully instead of breaking the page.
Browser support
SRI is supported across all current browsers: Chrome 45+, Firefox 43+, Safari 11.1+, Edge 17+, and Opera 32+. Internet Explorer 11 ignores the attribute and loads resources unverified, so treat SRI as a strong layer for modern visitors rather than a universal guarantee. Generate your hashes above, copy the finished tag, and paste it straight into your HTML.