There are many ferries and catamarans that can take you between Dar es Salaam and the Island. Azam Marine,Sea Express, Sea Star, SeagullKilimanjaro and Sepideh Megaspeed Liners are among the nicest available. Azam runs at 14h30 and 16h15 on weekdays and Sea Express at 07h30 daily. Fares range $35 to $40 for non-residents, including a $5 Port Tax. First class is only $5 more expensive than economy and certainly worth the money. Most ferries schedules allow you to do the return trip the same day. For instance leave Dar es Salaam at 07:30 and return from Zanzibar on the 16:30 ferry. That leaves plenty of time to explore the Stone Town, the museum and have a nice lunch. The trip is beautiful and lasts about two hours approximately. However, if the weather is bad it can take much longer and the trip can be very unpleasant. If you suffer from seasickness you are advised to take some anti-seasickness pills prior to boarding. The on board personnel hands out free sickness bags at the start of the journey. Flying Horse makes the same journey for $20. However, it will take around 4.5 hours whereas the others take 1.5 hours.
You may be able to hire a private boat for cheaper, but the trip will take considerably longer and unless you know something about boats, you could be on a vessel that is not equipped for bad weather conditions or an emergency. Remember: you get what you pay for.
Be aware that the "porters" at the Dar ferry terminal will hassle you for money and expect tips for referring you to "the best boat." If you don't want their help, be forceful. Touts will tell you anything to get you to use a service which pays them commission, and scam you in any way they can. They will say the company kiosk you are heading towards only goes to mainland destinations (when they do service Zanzibar), they will say their service is a 90min ferry (when it actually takes over 2 hours), they will quote you a price for first class tickets (but issue "e/c" economy tickets and pocket the difference), they will sell you a return ticket (leaving you to later find out it is actually only valid for return travel with a different, cheaper company and the seller has pocketed the difference). The dock is a zoo -- a prime hangout for pickpockets.
Passport. Although Zanzibar is part of the Union it maintains its own immigration service and you need to have a valid passport to enter, even if you come from mainland Tanzania. This farcically means you must fill out a Tanzania arrival card for your arrival in Stone Town, and a Tanzania departure card when you leave.