I think kostenlos and frei have the same meaning, but I really wonder if there is a very thin difference among these adjectives.
These words are often used in the same context, but each one of them has contexts, in which the other ones are less likely to be used.
When it comes to buying things, the one you should use is kostenlos. It literally means “without any costs”.
Gratis implies the same thing, but is in my experience used in cases, where someone tries to convince you or has already convinced you to buy something and then they or you highlight, that there is something else you’ll get (only) when buying, which you don’t need to pay for. When I hear the word gratis, I think of some situation, where there is a catch to a purchase and something is not as kostenlos as others want you to believe it is.
With umsonst you have to be a bit careful. For example in English you could say “Your efforts are for naught.” This is a case in which you could use umsonst. Umsonst’s actual meaning is closer to “without any use” than to anything implying that there are no costs. However, people use it for that as well. Another example of good usage: “Nun ist all unsere Arbeit umsonst”, which doesn’t mean that the work was not paid, but that the original goal of that work has either become irrelevant or impossible to reach.
Frei I’d say is the most general word of those. Frei is related to Freiheit (Freedom). In English you could probably say “I got that book for free”, but in German you couldn’t say “I habe das Buch für frei bekommen.” There are few cases, in which frei refers to the costs of something. There is for example Freibier, which means everyone gets some beer without having to pay for it.
When you use frei, try to use it when it is really about freedom and not about the costs. Here are some examples for the usage of frei:
- Die Gedanken sind frei. – One’s free to think whatever one likes, but it’s got nothing to do with any costs.
- Sie wollte frei sein wie ein Vogel. – She wanted to be free like a bird.
Oh and btw.: There is also kostenfrei, which means there are no costs attached to something and is the same as kostenlos. For some words you use the ending -los and for others you’d use -frei and for some you can use both to indicate a lack of whatever you appended those endings to.
Kostenlos and gratis are synonyms and both mean free (at no charge). But note that gratis is not declinable, i. e. you can only say:
- Sie erhalten eine Ausgabe gratis.
- Sie erhalten eine Ausgabe kostenlos.
- Sie erhalten eine kostenlose Ausgabe.
- Sie erhalten eine Gratisausgabe (wrong: “gratise Ausgabe”).
Umsonst is an alternative in spoken language, but you will rarely see it on advertisements or in articles because umsonst also means to no purpose in German. Umsonst is not declinable either.
Frei basically means in freedom. I don’t recommend using it in place of gratis. However, kostenfrei is another possibility.