Sleeping in your car is better than driving while tired and you will seldom get in trouble from the law for taking a nap. However, multiple laws govern the regulation of vehicles and how one can park in public and private areas. Laws are set not only by the California Department of Transportation, but also by municipal law.
The legality of sleeping in a car depends on how long you sleep, what time it is, where you are parked, and whether or not it is considered camping.
Difference Between Public and Private Property
Public property is property owned by the federal, state, county or city government. Typically this includes all government building parking lots, city streets, highways, and any national, city or county park. Private property is owned by anyone other than the government. This would include shopping centers, commercial buildings, non-governmental parks, and residential parking lots. If the car is parked on public property then state, county and city laws must be followed. If the car is parked on private property then you must have permission from the owner and follow the rules he may have.
When Parked at a Public Rest Stop
According to the California Department of Transportation, it is legal to have your car parked for up to eight hours in a 24-hour period in a rest area. However, it is illegal to "camp or pitch a tent." If you are merely taking a nap under eight hours long, it is most likely legal. But, if you consistently sleep in the same spot or have any items outside the car, a judge or officer will most likely determine your activity is camping which is illegal. If your car is a larger van or RV then it may look more like camping to the officer in which case you could be told to leave, given a ticket or even arrested.
When Parked at a Public Park
Municipal codes govern city parks and each county will have its own set of laws. In San Diego, it is illegal to camp or sleep in any public park or beach. Thus, one cannot sleep in a car in a public park or beach in San Diego County. In Los Angeles County, camping is only allowed where designated, and then only in accordance with the rules and regulations governing the use of such area. In San Francisco, no person shall occupy any "house car, camper or trailer coach for human habitation." This includes sleeping, eating or resting on any street, park, beach or public way within the County of San Francisco between 10:00 p.m. and 6:00 a.m. County municipal codes can usually be found online at the specific county clerk's office website.
When Parked on Private Property
When parked on private property it is important to know the property owner's rules. An owner can have your car towed or have the police remove you from the property if you are parked without permission. If you are at a private camping ground, there should be signs and most likely a posted fee. As long as you pay the fee and follow the owner's rules, this would be legal. If you don't pay the fees then you no longer have permission and are trespassing. If you are parked at a shopping center or on a commercial parking lot, the property owner would have to give you permission to sleep in your car. Generally, shopping centers only allow parking while the customer is shopping; thus, sleeping in your car would not be legal. Note that your car can get towed even if the owner gives you permission if you are blocking an entrance or fire hydrant.