1) You want to retain sole the rights to the IP and possibly license it for money to others some day. In this event, you should license it to your employer for a fee. However, this presents quite a tricky proposition of how you allocate time to spend on the tool vs time on your other work. If there is work to be done on the tool, you'd have to completely separate that from normal working hours, which may be impractical once the company is relying on said tool. The best way I can see to do that would be switching from employee to some kind of contractor role, where you could allocate time spent separately. As you can see this gets complicated.
2) You just don't want to give up the ownership completely to your company, but have no interest in ever charging for the tool. In that case, I'd suggest releasing it under an open source license prior to using it in your work. There are a variety of open source licenses available, and I feel like the pros and cons of each are well-worn territory already which can be examined with a simple Google search.
It seems like open source might be the way to go from your description above. In any case, you definitely need some kind of legal license in place, be it paid or open source.
I would add to #1 that since the tool is clearly related to the line of business of the company, even working on it outside the work hours may not be enough to keep it isolated.
So if some agreement is worked out with the employer on use of this tool, the same agreement may further include provisions for keeping it isolated.
For #2. Not sure how this would help, but it is also possible to release the source of the tool while still retaining full rights to it (i.e., release without a FOSS license). This can prevent the third parties from using the tool, and "may" provide some protection from the employer as evidence of what was developed before using it for work.
Note: IANAL.
As an aside, the mobile interface for this site makes it damn near impossible to make sure you are voting correctly. Sorry about the mistaken downvote.
The following is much better and does talk about many corner cases. It also is written specifically for the software-development case.
http://www.amazon.com/Intellectual-Property-Open-Source-Prot...
The book is written by software developers turned lawyers, and provided me with some fresh perspectives on the nature of the law itself.