Stanford is about 30 miles (~50 minutes) south of San Francisco and 20 miles (~35 minutes) north of San Jose, and is about the same driving distance from either airport. Here are some useful links:
Most parking lots have labeled slots (e.g., A, C), as well as a few public parking slots. Parking is regulated between the hours of 8am-4pm. Until 4pm, visitors may only park in the public parking slots. Beyond 4pm, you may park not only in the public parking slots for free, but also the labeled slots.
Parking costs $1.50 per hour until 4pm (each quarter gets you ten minutes). For all public parking slots, you can either use quarters, a printed parking permit, or a mobile payment option through Parkmobile.
The Stanford Parking and Transportation Services webpage has detailed information on where you can park.