In the RAE dictionary, the definition for "útil" sends you to "utensilio" as an "herramienta".
So, we can say "útil" and "herramienta" are the same, as the definition for "útil" includes the entrance "Herramienta o instrumento de un oficio o arte".
But this is not the only definition.
Outside this definition, an "útil" refers to two more definitions from the military world.
With this information we can say that "útil" meaning will vary depending the context of the text, if we are speaking about something like a tool, "útil" is the same as an "herramienta" so, in some way you can change between these two words.
Another way to know what to put in a text in Spanish. Is just practice, here in Spain, we refer to "herramienta" when we are speaking about something like a hammer some "heavy" tool, but when we speak about some tool more "light" as a knife to prepare fish almost always we will use "útil".
I'm adding here the two urls from the RAE dictionary in the Internet: