Not all companies offer this service. If your employer does offer this service, contact your HR department for specifics on how to obtain them online. They may have a specific website or code you would need to use to obtain them.
You can run a search on Google for W2's online. Here are a few companies I found, and you can check their database to see if your employer is listed: