City and county municipal codes are posted free on the Web by various local governments and publishers. Links to these free sites are are compiled by Municode.com, American Legal Publishing, eCode360 and Justia, in the "City Websites & City Codes" link for each state. If that doesn't work, look for the code on the municipality's Web site, use one or two good search engines and/or call the town/city/county clerk.
The Lexis has thousands of municipal codes online. You can search individual municipal codes, all the municipal codes in a given state, all the municipal codes in selected states or all the codes available on Lexis. You can get historical codes starting with 2012.
Westlaw's collection includes Charlotte (CHARLOTTE-MUN), Denver (DENVER-MUN), New York City (NYC-MUN), Minneapolis (MINNEAPOLIS-MUN), San Antonio (SANANT-MUN), and St. Paul (STPAUL-MUN).
Companies offering subscriptions for multi-jurisdiction searching include Municode.com, eCode360 and Ordinance.com.
If that doesn't do it, your best bet is generally to call the town, city, etc. Alternatively, a local library or the relevant State Library may be able to get you copies. If you're really stuck, you can post a request on a law librarian listserv.
Model Laws: The International Municipal Lawyers Association publishes a model municipal ordinance covering all the common areas of municipal law. The model ordinance is published -- with case annotations and cites to relevant state and local laws -- in the IMLA Model Ordinance Service. (Note: The IMLA was formerly called the National Institute of Municipal Law Officers, and the Service was titled the NIMLO Model Ordinance Service.
Sample code chapters are posted by topic by the National Association of Counties.
Public Safety Codes: Municipalities often have building codes, fire codes and other public safety codes "incorporated by reference" into their municipal code. These safety codes are written by outside organizations such as the International Code Council or "ICC" (formerly BOCA, ICBO and SBCCI), Underwriters Laboratories and the National Fire Prevention Association. Sometimes the municipality makes changes to the safety code, sometimes they use it as is.
A municipalities may post or publish its public safety codes as part of its municipal code, and Bulk.Resources.org posts a selection of safety codes for free. Otherwise, you have to buy the relevant code from the publisher or get copies from the municipality or a library with the code.
First Source provides information on the building codes of major cities and selected counties, as well as all 50 states.
Note: Many of the old BOCA, ICBO and SBCCI codes are still available from the ICC, and you can buy copies of sections from editions that are no longer available.
Treatises: For information on drafting local laws, see Matthews Municipal Ordinances (West). For an extensive discussion of the law of cities, towns, villages and counties, see McQuillan's The Law of Municipal Corporations, Antieau on Local Government Law and/or Local Government Law by Sands, Libonati and Martinez.