The Swedish G is pronounced differently depending on which letters surround it.
G in front of hard vowels (A, O, U, Å) and all consonants → [g]
G in front of soft vowels ( E, I, Y, Ö, Ä) and after R and J → [j]
G + N
G is pronounced like [ŋ] (ng) in front of an N.
In some loan words G is pronounced like [g] in front of E and I.
A few loan words, especially French, make the G sound like [ɧ].
If a French loan word ends on -ge, the -e is dropped and the G turns into [ɕ].
G at the end
Some consonants at the end of words get dropped in spoken Swedish. This concerns G and common words where you’ll see this phenomenon often are dag [dɑː(g)] and jag [jɑː(g)].
G + S or T
Like with B and D, G turns into it’s harder equivalent K after a short vowel and in front of S or T.
högst [høkst], the heighest, sagt [sakt], said.
Some important words make up the exception of this rule. Säga [”sɛja], to say, and mig [mɛj], me, dig [dɛj], you, and sig [sɛj], oneself/himself/herself. G is here pronounced like [j].