Even though starting a new business comes with many challenges and hardships, the vast majority of entrepreneurs are much happier than they were at their previous jobs.

According to a new survey from GoDaddy, 83 percent of small business owners are happier than they used to be at their old job, and 88 percent are optimistic about their company's prospects. More than 500 small business owners in a range of industries--consulting, retail, manufacturing, real estate, and many others--took part in the survey, conducted by Zogby Analytics in July and August.

One reason that entrepreneurs are so much happier is that they find themselves with much greater flexibility. More than half work from home, with one respondent even working from bed. And 15 percent said they could work in their pajamas if they wanted to.

The flexibility has a real impact on entrepreneur's lives, with 62 percent reporting that their day is unstructured and they are able to work around other activities. Additionally, 65 percent report having more time to spend with loved ones than in their previous positions. Many are also able to exercise during the regular workday and keep a healthier diet.

Starting a new business definitely presents its share of struggles, from acquiring new customers to establishing a digital presence to finding credit. Two-thirds of the entrepreneurs surveyed said they had to empty their bank account or accumulate credit card debt to get started. Nine percent took out loans, and 7 percent got help from friends and family.

"The challenges they face are largely how do I take those first steps, how do I finance my business," GoDaddy CEO Blake Irving said. "They're figuring out how to bootstrap for themselves. [They've] identified a need in the marketplace, how do [they] make people aware of it."

But at the end of the day, these entrepreneurs are willing to take on these issues in exchange for the freedom and flexibility that comes with the job.

"Even with the stress, they'll tell you, 'I'm happier. This is hard, but I'm fighting the good fight,'" Irving said. "My brother is an entrepreneur in Santa Fe, New Mexico. He can tell you how stressful it is trying to make payroll, but he loves his freedom."