You’ve had a hobby for years, but now want to turn it into a business, qualifying for tax deductions.

Can you?

The IRS has several tests.

“If someone has a business, they operate the business to make a profit,” the IRS says. “In contrast, people engage in a hobby for sport or recreation, not to make a profit.”

Hobbies becoming startups happens in various ways.

Ofer Kertes, an executive chef, would go downstairs from his Forest Hills apartment to his favorite Red Pipe Café. The owner was sometimes overwhelmed.

“I helped him out. It became a hobby to help,” Kertes said. “Suddenly my hobby was a business.” He is now part-owner of the Austin Street eatery.

Animal lover Gary Tambrin was a cable TV employee, but turned walking dogs into a business 12 years ago. He dumped cable and started Dogged Pursuits.

“I began walking some dogs to make ends meet and three dogs became five became seven, and so on.”

How can one go from hobby to business without an IRS headache?

“Keep records. Open up a separate credit card account that is dedicated to your business,” says Bernard Kiely, a Morristown, NJ, CPA.

Kiely says the general IRS rule is to post a profit in three years out of five. But he adds there is another safe harbor: “Are you doing things to try to make money even if you are not making money?”

Alistair Nevius, editor of the Tax Adviser, cites the case of boxer Joe Frazier. He had a money-losing farm in Brewton, SC, but was denied business deductions. However, Frazier said it was not “a hobby farm.”

He knocked out the pesky tax man in court and restored his deductions.