Guides › Text, code, and data
How to hash text with SHA-256 in the browser
Last updated 10 October 2026 · Written by Souren Das
The Hash Generator tab in Dev Tools hashes a string with the browser's Web Crypto API and shows the hex digest. FileTools Kit does not send that string to a hashing server. Use it to compare a value you have with a digest someone published, to check that two pieces of text are identical, or to learn how hashing behaves. It is not a password store.
What a hash is
A cryptographic hash turns any input into a fixed-length fingerprint. SHA-256 always gives 256 bits, shown as 64 hexadecimal characters, whether the input is one letter or a whole book. Three properties make it useful: the same input always gives the same digest; changing a single character changes the digest completely; and you cannot work backwards from the digest to the input. That is why software sites publish SHA-256 checksums next to downloads, and why systems compare hashes instead of storing raw secrets.
Hash versus encoding versus encryption
SHA-256 is a one-way digest. You cannot turn the hex back into the text. Base64 is encoding: anyone can decode it, as the Base64 guide shows. Encryption is reversible with a key. Do not treat a hash or Base64 as encryption, and do not paste a live password on a shared screen. This page does not offer MD5.
Steps
- Open Dev Tools and choose the Hash Generator tab.
- Replace the sample text in the box with your input. A trailing space or newline changes the digest.
- Press Generate hashes. The page shows SHA-1, SHA-256, SHA-384, and SHA-512 together.
- Copy the SHA-256 line.
- Compare it with the digest you were given, all 64 characters. A mismatch means the inputs are not the same, not that the tool failed.
Check the tool itself
Hash the three letters abc with nothing after them. SHA-256 should be:
ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
That value is the published test vector for SHA-256, so a match means the hashing is right and any other mismatch is in the input.
Why two digests differ
The text is encoded as UTF-8 before hashing, which is what most command-line tools and libraries do. A mismatch almost always comes from characters you cannot see:
- A trailing newline. The shell command echo adds one. Use echo -n "abc" | sha256sum on Linux, or printf.
- Line endings. Windows uses CR LF, Unix uses LF. Text copied between systems can change.
- A non-breaking space pasted from a web page looks like a space but is a different character.
- Curly quotes from a word processor instead of straight quotes.
- Case. Hex digests are case-insensitive to compare, but the input text is not: Hello and hello hash differently.
Reading the output
Output is lowercase hex. SHA-256 gives 64 characters, SHA-1 gives 40, SHA-384 gives 96, and SHA-512 gives 128. Compare the whole string, not the first few characters. SHA-1 is shown for checking old checksums. It is no longer considered safe against deliberate collisions, so do not choose it for anything new.
Worked example: confirming a value without resending it
Say a colleague set an API key in a server's configuration and you have the same key in your notes. You want to confirm they match without pasting the key into a chat. Each of you pastes the key into the Hash Generator, presses Generate hashes, and shares only the SHA-256 line. If the two 64-character strings match, the keys are identical. If they differ, one of you has a typo, an extra space, or an old key. The key itself never travelled. This only works for long, random values: for a short or guessable value, someone holding the hash can try likely inputs until one matches, so do not publish hashes of short secrets.
Text, not files
This tool hashes text you paste. It does not hash a file you download, such as an installer or an ISO image, so it cannot verify a download checksum directly. For that, use your operating system: sha256sum file on Linux, shasum -a 256 file on macOS, or Get-FileHash file in Windows PowerShell (it uses SHA-256 by default). Compare the result with the published value.
Why not to store passwords this way
SHA-256 is designed to be fast, which helps an attacker try billions of guesses. Password storage needs a deliberately slow algorithm with a unique salt per user, such as bcrypt, scrypt, or Argon2, run on the server. A single browser hash is not a password design. This tool is for comparison and learning.
Common mistakes
- Forgetting to replace the sample text before generating.
- Comparing only the first eight characters.
- Hashing a pasted line that carried an invisible newline.
- Expecting to reverse a hash to recover a value.
Privacy
Hashing runs with crypto.subtle in this tab. Nothing you type is sent to FileTools Kit. Even so, avoid pasting real passwords or API keys on a shared or screen-shared computer.
FAQ
Can two different inputs have the same SHA-256?
In theory yes, but nobody has found such a pair. In practice, matching digests mean matching inputs.
Why no MD5?
MD5 is broken for security use, and Web Crypto does not provide it.
Does it support HMAC?
No. Only plain digests.
Related guides: Base64 explained, JSON formatting explained, compare two text versions.
Written by Souren Das, FileTools Kit, Bengaluru. Last updated 10 October 2026. Spotted a mistake or a step that does not match the tool? Email support@filetoolskit.com and I will fix it. See how tools and guides are tested.