I think it's originated from Japanese "ちゃん(짱)" which is more informal than "さん(상)" or "さま(사마-very formal one)" ,and it is used to indicate "intimacy" with somebody putting it behind names.
However, the meaning of it has been changed in Korea.
It means "the best" or "superb!" and sometimes used in a sarcastic way depending on contexts.
Here are some examples.
1) 우와~ 짱이다!! - (I am very impressed and surprised to see or hear something) : surperb!
2) 넌 정말 짱이야 - (Thanks for lending me lots of money, my dear!, you are my sunshine! - your friend did your favor) : 넌최고야!
3) 니가 짱이다.: you are the best, we can't beat you.(니=you, very informal)
4) 그래 니가 짱이다.(in a sarcastic way) :(ok, I admit you are the best) you are something else.
"짱" is mostly used in very informal conversations. :)