If they write it in their free time, they could offer to sell it to their company for 2x yearly salary or something. Got a buddy that has done that 3 jobs in a row.
Depends on your contract. It’s not uncommon (or even necessarily unreasonable if you’re a full time employee) for a contract to stipulate that any code you write during the period of your employment that you make use of at work is owned by your company. I would imagine there are exceptions to this - I don’t think an employer could make a case that they own your Emacs scripts if you use them both at home and at work, and they certainly couldn’t try to take ownership of your side hustle that has absolutely nothing to do with your job - but for a fairly niche tool which produces value at your job, I think they’d be at least trying their hand at holding onto the IP if/when you leave, and restricting you from selling it on the side while you’re still employed. Probably also depends on the culture at your workplace and how decent your managers/bosses are.