I feel like I am pretty good at this. The key is to do a bunch of research upfront to know exactly what the market range of a typical person with your qualifications and skills is. As was mentioned already, glassdoor.com is your friend here. There were a couple other places I looked...don't remember right now, but just google your job title with salary after it and you will come up with a few places.
Then if you have some skills or differentiating factors for yourself above and beyond what other people with similar qualifications have, aim slightly above the high end of the salary range. If you can't think of anything that differentiates yourself, that is ok too, aim for the middle to upper end of the salary range.
The final and most important bit is to believe that you are worth what you are asking for. This is always the hardest part for me. I still have a hard time believing I am actually worth what they pay me, but I know that they bill me out at a hourly rate of approx. 4.5x what my salary would be on an hourly basis (which I REALLY can't justify), so it makes it a bit easier for me to justify what they pay me.
Some people think it is best to not be the first to say a salary range in negotiations, but if you have done your research I would argue it most certainly is best to say a range first since it acts as an anchor point for any counter offers. But, always say a range not a specific number... something like "I believe someone with my qualifications and skills would be in the range of xxx,xxx to x,xxx,xxx" (see what i did there :P).
Ideally the low end of your range will be your target salary or slightly above your target salary that way if they go anywhere in your range you will be happy. The overall goal though is to set your range ever so slightly above what they would want to pay you, but not to the point of being unrealistic.
When I started, my offered salary (they went first--first job I didn't know what I was doing) was slightly above the average for an entry level person. I asked for 5% justifying it with superior qualifications --> I received 3% above the initial offer which put me in the mid-high range. I received yearly bumps of around 5% the next three years for good performance which kept me at the high end of the salary range.
At the start of my fourth year (about 2 months after I had just received a 5% bump) I knew I was going to be switching companies so I decided to sack up and ask for a substantial raise before jumping ship so I could negotiate from a higher base salary. I justified it by citing that my responsibilities had begun to exceed my compensation (which was a valid point but a bit exaggerated) and that I had just received a professional license (also valid but typically only results in about a 5% bump most places). I had prepared a lot of materials to back up the highest bump that I could justify which would have been a 20% bump from where I was at.
As it turned out though my bosses boss (who I had a pretty good relationship with) went to bat for me with upper management and apologetically informed me that he was only able to get me a 13% bump. This was without me doing anything other than asking for a raise. I didn't try to counter that one since it was right on target with where I was trying to end up at.
When I was interviewing at new companies none of the companies directly balked at the range I suggested I was worth. The low point of the range I gave was 11% above the high end of the range for someone with my experience on glassdoor.com and the high end of the range I gave was where people in my profession typically plateau at. I effectively priced myself at someone with 3x the experience I have but was able to justify it with my current at the time salary. The company I ended up at came back slightly below my specified range which I happily accepted since it was just slightly below where I hoped to end up at but was well within what I was prepared to accept to switch over to them.
Since I am still sitting off the scale as far as salary for someone with my experience, in my review this year instead of asking for a raise I asked to receive my end of year guaranteed bonus at the beginning of the year from now on instead of the end. They agreed to that. Next year I will try for a 3% raise by asking for a 5% raise which they should be more willing to oblige since I didn't ask for one this year.
In all I have increased my salary approx. 40% over 5 years for always asking for slightly more than I think I deserve, and asking for a raise after achieving professional milestones...the smartest thing I did was asking for a substantial raise and then changing companies shortly after to get another bump...that move alone bumped my salary 20% from the previous year and has my current salary sitting off the scale. The unfortunate side effect of this is I am only about 15% away from the high end of the typical plateau for my position that most people take about 20 years to get to...so any increases from here on out will likely be small and very gradual.