Freedom camping, a.k.a. “wild” camping is only allowed in designated Freedom Camping locations. A majority of these locations require that you can only freedom camp in a “self-contained” vehicle, a camper van that has a toilet and a container for grey water. This means that there are not many places where you can freedom camp if you are limited to your backpack and tent.
More details on freedom camping can be found here.
New Zealand's Department of Conservation (DOC) operates conservation campsites throughout the country. They are normally free to use but sometimes you may need to pay ~$6 NZD ($5 USD) per person per night. Note that it is usually not easy to access these campsites unless you have a vehicle or if you are tramping in the backcountry.
A list of DOC campsites can be found here.
The DOC has 950+ huts found throughout NZ, these are sheltered areas that have amenities ranging from just a roof to bunks with mattresses and a firepit. Some of the huts are free to use, but you may need to pay upwards of $15 NZD for a nights stay per person. The huts along the Great Walks are more expensive. A 6 month or 1 year backcountry hut pass can be purchased. Most of the huts operate on a first come, first serve basis, but it it possible to place a reservation for some huts.
A list of DOC Backcountry Huts can be found here.
A DOC hut seen in the background
There are a number of privately run campgrounds, called Holiday Parks, found through out New Zealand. They can be pricey, ranging in rates from $16-20 NZD ($13-16 USD) per person per night. Often located in or just outside of towns.
Hostels are one of the cheapest options for sleeping in a city or large town. A dorm bed can cost anywhere from $20-30 NZD ($16-24 USD) per night. All hostels have public kitchens for guests to use at no additional cost. Normally, you must pay to use the hostel's WiFi.
If you do not want to pay for WiFi at a hostel, be sure to visit the local public library where you can usually find free WiFi. There are a few libraries that do charge for WiFi (eg. Rotorua).
It is possible that you may be invited to stay the night at a Kiwi's home. The probability of this happening increases if you are hitchhiking.
I met one Kiwi who reckoned that if you picked up a phone book and started to call people randomly, explaining your situation and that you needed a place to sleep for the night, that you would be able to find accommodation. There really are many friendly and helpful people living in New Zealand.