Her comes before a noun or acts as an object; hers stands alone with no noun following it. That is her umbrella, and I gave it back to her. The blue umbrella is hers. When the word is marking possession, a noun after it means her.
The core difference
Her does two jobs. It marks possession in front of a noun (her car, her idea, her turn), and it works as an object pronoun (I met her, tell her, sit next to her). Hers does one job: it replaces a possessive and its noun together, so nothing follows it.
Compare the pair directly:
- Her desk is by the window. → The desk by the window is hers.
- I borrowed her charger. → I borrowed a charger of hers.
The test you can run
First establish that the word is marking possession — that it answers "whose?". If it does, look at what comes immediately after it. A noun follows, use her. Nothing follows, use hers.
The test only applies to possessives, because her is also the object form, and there nothing follows it either: "I gave it back to her", "I met her", "sit next to her". None of those are about whose something is, so hers is never an option in them.
A second check for the possessive cases: swap in my and mine. Wherever my fits, use her; wherever mine fits, use hers. Do not use his for this — his covers both possessive slots, so it cannot tell them apart, and it does not cover the object slot at all (the object form is him).
The mistake to watch for
Hers never takes an apostrophe. Her's is not a word in any variety of English. The confusion comes from ordinary possessives like Sarah's coat, where the apostrophe is doing real work. Possessive pronouns are a separate set and none of them use one: hers, his, its, ours, yours, theirs. If you write her's, you are also likely writing your's and their's — the fix is the same rule for all of them.
The other error is using hers in front of a noun: "hers coat" instead of "her coat". This is rare among first-language speakers but common for learners whose own language has only one possessive form.
Two constructions worth knowing
Of hers is a normal, natural pattern: "a friend of hers", "that habit of hers". It is not redundant, and it is not the same as "her friend" — "a friend of hers" implies one among several.
In more formal writing you may meet hers at the start of a clause: "Hers was the only objection." This is correct and still current, though it sounds elevated. In speech most people would say "She was the only one who objected."
Finally, her is also used as an object after prepositions — with her, for her, about her. If you are choosing between her and she rather than between her and hers, the question is subject versus object: she does things, things happen to her.