I'm guessing that there is a cognitive divide here, between:
1. people who apply for jobs they see ads for, by just doing the phone screen + showing up at the interview; and
2. people who know someone who works at the company, have heard stories of how the company is, see people from the company getting lunch around town, might have even informally asked the person-qualified-to-make-hiring-decisions whether they're hiring--and then go through the interviewing process.
In the latter case, you obviously know exactly what the dress code is like before getting there.
Different places have different expectations, and there's no reliable way to know in advance what those expectations are going to be -- other than asking. I think most employers understand that.
If you can afford to say you wouldn't want to work at a place that expects a suit and tie for an interview, that's great -- but not everyone has that luxury.
Asking what to wear has generally worked just fine for me.
1. people who apply for jobs they see ads for, by just doing the phone screen + showing up at the interview; and
2. people who know someone who works at the company, have heard stories of how the company is, see people from the company getting lunch around town, might have even informally asked the person-qualified-to-make-hiring-decisions whether they're hiring--and then go through the interviewing process.
In the latter case, you obviously know exactly what the dress code is like before getting there.