SRI Hash Generator

Generate SHA-256, SHA-384, and SHA-512 Subresource Integrity hashes for scripts and stylesheets. Get ready-to-use integrity attributes and full HTML tags.

Last reviewed: June 2026

New to this tool? Click here for instructions

Paste file content above to generate SRI hashes.

How to Use the SRI Hash Generator

Use Text / Paste when you already have the exact JavaScript or CSS file content. Paste the file contents, not an HTML <script> or <link> tag, and the SHA-256, SHA-384, and SHA-512 integrity values update automatically.

Use File Upload for a local file you downloaded or built. The browser reads the file into memory with FileReader and hashes that byte-for-byte content. Use URL Check for a public CDN URL that allows cross-origin fetches; the browser downloads the file directly, then hashes the response bytes locally.

When to Use the Tool in Real Workflows

Subresource Integrity is useful when you load versioned scripts or stylesheets from a CDN and want the browser to block the resource if the fetched bytes differ from the expected hash. It is most useful for static, pinned assets such as a specific package version on jsDelivr, cdnjs, or an internal asset host.

After generating a hash, enter the resource URL in the Resource URL field so the generated <script> and stylesheet <link> examples contain the same URL you will use in production.

How It Works

Pasted text and dropped files are hashed locally with the Web Crypto API's crypto.subtle.digest(). Nothing is uploaded to a ThisDevTool server. URL Check is different: your browser fetches the URL you entered from the remote CDN, subject to that host's CORS policy, and then hashes the downloaded bytes locally.

Tips, Edge Cases, and Limitations

Hash the exact file bytes the browser will receive. Minified and unminified builds, redirects to different versions, build timestamps, injected banners, or CDN transformations will produce different hashes. If the resource changes after deployment, update the integrity value or the browser will block it.

Use crossorigin="anonymous" with cross-origin SRI resources. SHA-384 is a practical default because it is strong and keeps the integrity string shorter than SHA-512, while SHA-256 and SHA-512 remain available for compatibility with your policy.

Sources Checked

Reference behavior was checked against MDN documentation for Subresource Integrity, SubtleCrypto digest, and CORS.

Frequently Asked Questions

Subresource Integrity (SRI) is a browser security feature that lets you verify that files fetched from a CDN or third-party host have not been tampered with. You add an integrity attribute containing a cryptographic hash to your <script> or <link> tags. Before executing or applying the resource, the browser computes the hash of the downloaded file and compares it to the value in the integrity attribute. If they don't match, the browser blocks the resource.
SHA-384 is the recommended algorithm for SRI. It provides a strong security margin and is well-supported in all modern browsers. SHA-256 is acceptable but offers less collision resistance. SHA-512 provides the highest security but produces the longest hash strings. You can include multiple hash values separated by spaces (e.g. integrity="sha256-... sha384-...") and the browser will use the strongest supported algorithm.
Most major CDNs publish SRI hashes alongside their hosted files. jsDelivr (jsdelivr.com) shows integrity attributes on every package page. cdnjs.cloudflare.com includes the hash next to download links. The official Bootstrap and jQuery download pages also list SRI hashes. You can also generate them yourself with this tool by pasting the file content or using the URL Check tab.
No. SRI requires the file content to be identical every time it is served. If a server generates slightly different output on each request (timestamps, random nonces, personalized content), the hash will never match and the browser will block the resource. SRI is designed for static, versioned assets such as npm packages served from a CDN. For dynamic resources, use Content Security Policy (CSP) nonces instead.
No. This SRI hash generator runs 100% in your browser using the Web Crypto API (SubtleCrypto). Pasted text and dropped files are processed entirely in memory. Nothing is uploaded to any server. There is no logging, no cloud processing, and no data retention of any kind.

Quick reference

SRI hash generator reference
ModeInputImportant note
Text / PasteExact JS or CSS file contentHashes the pasted bytes in the browser.
File UploadAny local fileReads the file locally; no upload is performed.
URL CheckCORS-enabled CDN URLYour browser fetches the remote file before hashing it locally.
HTML tagsSelected hash plus resource URLAdds integrity and crossorigin="anonymous".

Example walk-through

Generate an integrity attribute for a static script

Step 1. Download or copy the exact contents of the JavaScript file you plan to load from a CDN.

Step 2. Paste the file content into Text / Paste mode. The output should start with sha256-, sha384-, and sha512-.

Step 3. Keep SHA-384 selected, then enter the public CDN URL in Resource URL.

Step 4. Copy the generated script tag and use it with the same versioned URL.

<script
  src="https://cdn.example.com/app.min.js"
  integrity="sha384-..."
  crossorigin="anonymous"
></script>

Step 5. If the CDN file changes, regenerate the hash before deploying the tag.