SRI Hash Generator

Generate the integrity="sha384-…" value for script and link tags.

Result

sha384-M5mGpKxRozBpvsX+PXs0ssm1NdoBYDPN4gQsyCwq+RTqmuLt5T6LWQKklQd4sArc

<script src="https://example.com/app.js" integrity="sha384-M5mGpKxRozBpvsX+PXs0ssm1NdoBYDPN4gQsyCwq+RTqmuLt5T6LWQKklQd4sArc" crossorigin="anonymous"></script>
3 lines · 231 bytes
  • The hash must be of the exact bytes the server sends, including line endings. Paste the file as downloaded, not as re-saved by an editor.

What is Subresource Integrity (SRI)?

Subresource Integrity lets a browser check that a script or stylesheet loaded from another server has not been altered. You add an integrity attribute containing a hash of the file, such as sha384-... If the file the browser receives does not match, it refuses to use it.

This protects your page if a CDN or third-party host is hacked or serves a changed file. The value is the name of the algorithm, a hyphen and the hash written in Base64. This tool takes the exact contents of the file, builds that value and wraps it in a script or link tag with crossorigin set.

How to use the SRI Hash Generator

  1. Paste the exact contents of the file.
  2. Choose the algorithm, with SHA-384 as the default.
  3. Enter the file's URL so it appears in the tag.
  4. Copy the integrity value or the full tag.

Real situations

When people use the SRI Hash Generator

  • 1

    Add integrity to a CDN script

    Hash the library file you load from a CDN, then paste the integrity attribute into your script tag.

  • 2

    Protect a third-party stylesheet

    Generate the value for a CSS file and get a ready link tag with the right attributes.

  • 3

    Update after a version change

    When you upgrade a library, compute the new hash so the old integrity value does not block it.

  • 4

    Check a value from documentation

    Paste a file and compare the hash with the one a project publishes.

FAQ

SRI Hash Generator: questions answered

Which algorithm should I use for SRI?

SHA-384 is the usual recommendation and is the default here. SHA-256 and SHA-512 are also accepted by browsers. Do not use MD5 or SHA-1 for SRI.

Why does my integrity hash not work?

The hash must be of the exact bytes the server sends. A different line ending, a trailing newline, an editor that re-saved the file or a compressed copy changes it. Copy the file as downloaded and hash that.

What does the hash look like?

The sample text console.log("hello"); followed by a new line gives sha384-M5mGpKxRozBpvsX+PXs0ssm1NdoBYDPN4gQsyCwq+RTqmuLt5T6LWQKklQd4sArc with SHA-384. The part before the hyphen names the algorithm.

Why is crossorigin="anonymous" in the tag?

For files from another origin, the browser needs permission to read the content in order to check it. The crossorigin attribute asks for that, and the server must allow it with the right CORS headers.

Does SRI work for files that change?

No. If the file changes, the check fails and the browser blocks it, which is the point. Use SRI only on versioned, fixed files, not on URLs that always return the latest version.

Does the tool detect stylesheets?

Yes. If the URL you enter ends in .css, you get a link tag for a stylesheet. Otherwise you get a script tag.

Is this SRI Hash Generator free and private?

Yes. It is free with no sign-in, and every calculation runs inside your browser. Nothing you type is sent to a server or stored, and the page keeps working offline once it has loaded.

Private by design. No accounts, no cookies, no tracking. Everything you type stays on your device.

How we keep it that way