Java String HashCode Calculator
Reproduce Java String hashCode exactly from browser text.
Match Java signed 32-bit string hashing
Java String hashCode starts at zero and updates with previous hash times 31 plus the next UTF-16 code unit, wrapping as a signed 32-bit integer. This calculator follows that contract directly, reporting signed decimal and the same bit pattern as eight unsigned hexadecimal digits. It helps debug map keys, serialized fixtures, tests, and cross-language ports that must reproduce Java behavior.
The string hello returns signed decimal 99162322 and hexadecimal 05e918d2. Java hashes UTF-16 code units rather than Unicode code points or UTF-8 bytes, so supplementary characters contribute their surrogate pair as two steps. That detail explains many mismatches with byte-oriented hashes even when both tools display the same visible text.
Remember that hashCode is a runtime contract, not security
Equal Java strings always share a hashCode, but different strings may legally collide; the famous collision pairs are a reminder that hashCode never proves identity. The computation stays in your browser. Do not use this value for passwords, signatures, tamper detection, or persistent security identifiers, and compare full strings whenever correctness depends on equality.
Frequently Asked Questions
Why can Java hashCode be negative?
The 32-bit result is interpreted as a signed two-complement integer, so its high bit can produce a negative decimal value.
Does Java hash UTF-8 bytes?
No. String hashCode iterates UTF-16 code units, including both halves of a surrogate pair.
Do equal hash codes mean equal strings?
No. Java requires equal strings to share a hash, but unrelated strings are allowed to collide.
Browse the full set of free, private, in-browser tools.