I am asking for general use, when it is not clear whether you should be talking in formal/informal.
Taking "formally" to mean 丁寧語 here, I think it depends.
If you use your real name, I think the usual rules apply (which are too complex to fully describe here, but I'll mention some aspects). Use 丁寧語 with people you don't know well and people older than you. If you aren't talking at someone (say, a non-@ tweet, or saying something random in a chatroom), then no 丁寧語 seems to be mostly fine. Also like in real life, if you are much older then you can drop the 丁寧語 with younger people. There are of course some people who break this pattern and just almost never use 丁寧語 when chatting despite using their real name, but I think that is not too common.
If you don't use your real name, and especially if you're also talking to someone else who doesn't use their real name, then there's no real need for 丁寧語 as far as I can tell. This is quite common on 2ch, IRC, ニコニコ, etc. where most people don't bother using it.
I think 丁寧語 is quite common on forums and Q&A sites, regardless of if you're using your real name. I guess it's just because they have a more serious feel to them, and because you're often asking things of people.
Things might be more detailed or different than this in certain places, but it's what I've determined personally.