That's a tricky one. Unless you actually know someone it is very difficult to tell, especially online, where anyone can pretend to be whatever they want to be!
If you are a sociable and easy going person, you will probably want to meet new people online, and that's ok. You just need to remember to set boundaries and not assume that you can trust someone just because they are being friendly. It is possible to check someone out before connecting with them, such as their social media etc. This would give you some idea of whether they are genuine or not. I get regular friend requests on Facebook from people I don't know and I always take a look on their profile page to see if they are genuine or not, or if they are the sort of person I would like to get to know. If I don't like the look of them, or the content of their page, I delete them. Simple.
Real friends means just that. People that you actually know, not people who may or may not be who they say they are online. If you get on with someone online and like what they say or like the same things as them etc then you will feel comfortable treating them like a friend, but it does not mean they are your friend at all, it's just you feeling comfortable connecting with them. Try not to invest too much of yourself into online relationships, like I say, you never really know what a person is really like unless you actually know them, and even then it can be difficult!